public class Helpers extends Activity implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener {SharedPreferences preferences;private static final String TAG = "BaseDriveActivity";public static String EXISTING_FOLDER_ID;protected static final int REQUEST_CODE_RESOLUTION = 1;protected static final int NEXT_AVAILABLE_REQUEST_CODE = 2;public static final String folderId = "FOLDER_ID";public static final String fileName = "folderId";private GoogleApiClient mGoogleApiClient;@Overrideprotected void onResume() { super.onResume(); if (mGoogleApiClient == null) { mGoogleApiClient = new GoogleApiClient.Builder(this) .addApi(Drive.API) .addScope(Drive.SCOPE_FILE) .addScope(Drive.SCOPE_APPFOLDER) // required for App Folder sample .addConnectionCallbacks(this) .addOnConnectionFailedListener(this) .build(); } mGoogleApiClient.connect();}@Overrideprotected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == REQUEST_CODE_RESOLUTION && resultCode == RESULT_OK) { mGoogleApiClient.connect(); }}@Overrideprotected void onPause() { if (mGoogleApiClient != null) { mGoogleApiClient.disconnect(); } super.onPause();}我想安装应用程序时创建一个文件夹,然后获取其ID并将其保存到sharedprefrences ..此后,我想在该文件夹中创建一个文件,但是当我使用传递该folderID在其中创建文件时,它会说 “无法找到DriveId。您是否有权查看此文件?”如果我result.getDriveFolder().getDriveId().getResourceId() 用来获取ID的话,它总是会为null。我正在使用此代码首先创建粘贴了https://github.com/googledrive/android-demos/blob/master/src/com/google/android/gms/drive/sample/demo/CreateFolderActivity.java的文件夹并在文件夹中创建文件,我正在使用本指南 https://github.com/googledrive/android-demos/blob/master/src/com/google/android/gms/drive/sample/demo/CreateFileInFolderActivity.java我通过folderiD我保存的文件,并通过它创建文件功能。
1 回答
- 1 回答
- 0 关注
- 313 浏览
添加回答
举报
0/150
提交
取消