要强制Android应用程序仅使用某个帐户来使用Google Drive API (GDAA),可以按照以下步骤进行操作:
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.INTERNET" />
<application>
...
<service
android:name="com.google.android.gms.auth.api.signin.RevocationBoundService"
android:exported="true"
android:permission="com.google.android.gms.auth.api.signin.permission.REVOCATION_NOTIFICATION" />
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
</application>
GoogleApiClient googleApiClient = new GoogleApiClient.Builder(this)
.addApi(Drive.API)
.addScope(Drive.SCOPE_FILE)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.build();
googleApiClient.connect();
Drive.DriveApi.getAppFolder()
方法来获取应用程序的专用文件夹。Drive.DriveApi.getAppFolder(googleApiClient)
这样,应用程序将仅使用用户选择的特定Google账号来访问和操作Google Drive API。
领取专属 10元无门槛券
手把手带您无忧上云