Google Drive Android API教程问题

时间:2014-06-26 00:45:46

标签: android google-drive-android-api

关注this tutorial后,我将此代码粘贴到我的主要活动中:

@Override
public void onConnectionFailed(ConnectionResult connectionResult) {
    if (connectionResult.hasResolution()) {
        try {
            connectionResult.startResolutionForResult(this, RESOLVE_CONNECTION_REQUEST_CODE);
        } catch (IntentSender.SendIntentException e) {
            // Unable to resolve, message user appropriately
        }
    } else {
        GooglePlayServicesUtil.getErrorDialog(connectionResult.getErrorCode(), this, 0).show();
    }
}

我最终必须导入buncha库,但我仍然无法修复此错误:

RESOLVE_CONNECTION_REQUEST_CODE cannot be resolved to a variable

任何想法???我无法弄清楚哪个库包含此常量...

1 个答案:

答案 0 :(得分:12)

当教程指定从一个Android项目开始时,它们意味着一个Google Drive android项目,它具有不同的导入和类定义,这些都没有从教程中明确说明。他们实际上为Google Drive android项目提供了一些入门代码,但他们将其误标为仅仅是一个" Android快速入门"所以我认为它与任何其他Android项目没有什么不同。

enter image description here

此处链接的位置为Google Drive Android Quickstart,如果您使用此代码作为参考,教程会更有意义。

如果有人对原始问题的解决方案感到好奇,那么常量应该是 REQUEST_CODE_RESOLUTION,但同样,还有更多更改,所以只需使用Google Drive Android Quickstart