Android Google Drive EXISTING_FOLDER_ID,EXISTING_FILE_ID

匆匆过客 提交于 2019-12-13 06:40:56

问题


In BaseDemoActivity.java from Google Drive Demo app

https://github.com/googledrive/android-demos/blob/master/src/com/google/android/gms/drive/sample/demo/BaseDemoActivity.java

what i have replace in EXISTING_FOLDER_ID,EXISTING_FILE_ID,EXTRA_ACCOUNT_NAME

Please provide steps to get this values

 /**
 * DriveId of an existing folder to be used as a parent folder in
 * folder operations samples.
 */
public static final String EXISTING_FOLDER_ID = "????";

/**
 * DriveId of an existing file to be used in file operation samples..
 */
public static final String EXISTING_FILE_ID = "????";

/**
 * Extra for account name.
 */
protected static final String EXTRA_ACCOUNT_NAME = "????";

Thanks


回答1:


The first part, EXISTING_FOLDER_ID,EXISTING_FILE_ID, is answered in SO 21800257, but be careful. You can't just go to a web Drive interface, create a file, copy/paste its resource id ... Google Drive Android API (GDAA) supports only FILE scope, so only files, folders created by your Android App are eligible.

EXTRA_ACCOUNT_NAME is a name of your Google (gmail) account (myaccount@gmail.com). That's the one you would need here:

GoogleApiClient mGac = new GoogleApiClient.Builder(contex)
 .addApi(com.google.android.gms.drive.Drive.API)
 .addScope(com.google.android.gms.drive.Drive.SCOPE_FILE)
 .setAccountName(EXTRA_ACCOUNT_NAME)
 .addConnectionCallbacks(context).addOnConnectionFailedListener(context)
 .build();

but I'm not sure the demo even addresses this. You would use it if your Android App allowed switching between different accounts.



来源:https://stackoverflow.com/questions/27466683/android-google-drive-existing-folder-id-existing-file-id

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!