AccountManager blocksGetAuthToken 卡住了 [英] AccountManager blockingGetAuthToken gets stuck
问题描述
我一直在使用 SampleSyncAdapter作为创建我自己的 SyncAdapter 的基础.添加新帐户似乎很有效,但是一旦我想使用 AccountManager.blockingGetAuthToken(... 获取身份验证令牌,它就会卡住,然后在几分钟后抛出 OperarationCanceledException.
I've been using the SampleSyncAdapter as a base to create my own SyncAdapter. It seems to work well to add a new account, but once I want to get the authtoken with AccountManager.blockingGetAuthToken(... it gets stuck and then throws an OperarationCanceledException after a few minutes.
有没有人知道这里可能出了什么问题?代码与示例几乎相同,只是我正在对自己的服务器进行身份验证.
Does anyone have an Idea of what could be wrong here? The code is almost the same as the sample except I am authenticating towards my own server.
05-24 23:00:23.258:错误/同步适配器(4961):OperationCanceledExcetpion05-24 23:00:23.258:错误/同步适配器(4961):android.accounts.OperationCanceledException05-24 23:00:23.258:错误/同步适配器(4961):在 android.accounts.AccountManager$AmsTask.internalGetResult(AccountManager.java:1255)05-24 23:00:23.258:错误/同步适配器(4961):在 android.accounts.AccountManager$AmsTask.getResult(AccountManager.java:1260)05-24 23:00:23.258:错误/同步适配器(4961):在 android.accounts.AccountManager$AmsTask.getResult(AccountManager.java:1181)05-24 23:00:23.258:错误/同步适配器(4961):在 android.accounts.AccountManager.blockingGetAuthToken(AccountManager.java:737)
05-24 23:00:23.258: ERROR/SyncAdapter(4961): OperationCanceledExcetpion 05-24 23:00:23.258: ERROR/SyncAdapter(4961): android.accounts.OperationCanceledException 05-24 23:00:23.258: ERROR/SyncAdapter(4961): at android.accounts.AccountManager$AmsTask.internalGetResult(AccountManager.java:1255) 05-24 23:00:23.258: ERROR/SyncAdapter(4961): at android.accounts.AccountManager$AmsTask.getResult(AccountManager.java:1260) 05-24 23:00:23.258: ERROR/SyncAdapter(4961): at android.accounts.AccountManager$AmsTask.getResult(AccountManager.java:1181) 05-24 23:00:23.258: ERROR/SyncAdapter(4961): at android.accounts.AccountManager.blockingGetAuthToken(AccountManager.java:737)
推荐答案
blockingGetAuthToken
方法是同步调用 getAuthToken
的辅助方法.
The blockingGetAuthToken
method is a helper that calls getAuthToken
synchronously.
如果您正在访问网络以检索身份验证令牌,您将被阻止,直到请求成功.您应该检查您是否可以从应用程序中正确访问网络资源.
If you are accessing the network to retrieve the auth token you will be blocked until the request succeeds. You should check that you can access the network resource properly from within your application.
这篇关于AccountManager blocksGetAuthToken 卡住了的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!