共享驱动器的SDK第2版和谷歌云端硬盘Android API之间的凭证驱动器、云端、凭证、硬盘

由网友(相关好听的四字推荐)分享简介:这里的另一个坑跌试图实施新的谷歌云端硬盘Android API(到时GDAA):我的应用程序的活动A 需要不GDAA支持的功能,所以我诉诸使用原始的谷歌驱动器SDK V2每声明这里 : here's yet another pit a fell into when trying to implement the ne...

这里的另一个坑跌试图实施新的谷歌云端硬盘Android API(到时GDAA):我的应用程序的活动A 需要不GDAA支持的功能,所以我诉诸使用原始的谷歌驱动器SDK V2每声明这里 :

here's yet another pit a fell into when trying to implement the new Google Drive Android API (GDAA): Activity A of my app needs functionality not supported by GDAA, so I resort to using the original Google Drive SDK v2 per the statement here.:

在某些情况下,应用程序可能需要使用谷歌云端硬盘网络  服务来访问附加功能或高于大盘的访问范围  什么谷歌云端硬盘Android API中可用。在这些情况下,  您的应用程序必须使用谷歌API客户端库的Java。

In some cases, applications may need to use the Google Drive web service to access additional features or access broader scopes than what is available in the Google Drive Android API. In these cases, your application must use the Google APIs Client Library for Java.

中的授权顺序为标准:

...
GoogleAccountCredential credential = GoogleAccountCredential.usingOAuth2(this, DriveScopes.DRIVE_FILE);
credential.setSelectedAccountName(accountName);
...

与DRIVE_FILE范围的认证/授权是成功的。

The authentication / authorization with DRIVE_FILE scope is succesful.

在活动B ,我用的是GDAA,通过标准的顺序去

In Activity B, I use the GDAA, going through the standard sequence

X =新GoogleApiClient.Builder(本)....构建(); x.connect() onConnectionFailed() startResolutionForResult()

这就是问题出现在哪里。用户已通过帐户的选择和授权活动A去了,但GDAA不知道这件事。这将导致一个新的帐户选择对话框再次弹出。所以,问题是:有没有一种方法来传递初始化凭据GDAA无需再次窃听用户(范围是相同的)? 如果应用程序需要同时使用谷歌驱动SDK V2 并GDAA(如将可能是任何情况下,但最简单的应用程序),显示不止一次账号选择对话框中肯定会有一个搅局者。

and this is where the problem appears. The user already went through account selection and authorization in Activity A, but GDAA does not know anything about it. This causes a new account selection dialog to pop up again. So the question is: Is there a way to pass the initialized credentials to GDAA without bugging the user again (scope's the same)? If the app needs to use both Google Drive SDK v2 and GDAA (as will probably be the case for any, but most trivial app), showing the account selection dialog more than once will certainly be a showstopper.

推荐答案

在建立一个新的GoogleApiClient,可以明确设置的帐户名称。

When building a new GoogleApiClient, you can explicitly set an account name.

x = new GoogleApiClient.Builder(this)
       .addScope(Drive.SCOPE_FILE)
       .setAccountName(accountName)...

由于应用程序授权的帐户时,它会自动连接。

Since the application is authorized for the account, it will automatically connect.

阅读全文

相关推荐

最新文章