gpt4 book ai didi

android - AsyncTask 在尝试获取 token 时触发错误消息

转载 作者:行者123 更新时间:2023-11-30 01:51:29 24 4
gpt4 key购买 nike

我试图在后台获取 token 以使用 google playservices 验证我自己,但我无法这样做。

我获取token的代码如下,

private class GetTokenTask extends AsyncTask<String, Void, String> {

@Override
protected String doInBackground(String... params) {
try {
return fetchToken(params[0]);
} catch (IOException e) {
return null;
}
}

@Override
protected void onPostExecute(String result) {
if (result != null) {
ProximityApi.getInstance(MainActivity.this)
.setAuthToken(result);
setResult(RESULT_OK);
finish();
}
}
}

我得到的错误响应如下,

10-06 03:05:08.855    1876-1893/com.infotech.palmtree.proxybeacon W/art﹕ Suspending all threads took: 21.270ms
10-06 03:05:11.402 1876-1893/com.infotech.palmtree.proxybeacon W/art﹕ Suspending all threads took: 65.002ms
10-06 03:05:11.463 1876-2140/com.infotech.palmtree.proxybeacon W/System.err﹕ com.google.android.gms.auth.UserRecoverableAuthException: DeviceManagementSyncDisabled
10-06 03:05:11.634 1876-2140/com.infotech.palmtree.proxybeacon W/System.err﹕ at com.google.android.gms.auth.GoogleAuthUtil.zza(Unknown Source)
10-06 03:05:11.634 1876-2140/com.infotech.palmtree.proxybeacon W/System.err﹕ at com.google.android.gms.auth.GoogleAuthUtil.getToken(Unknown Source)
10-06 03:05:11.634 1876-2140/com.infotech.palmtree.proxybeacon W/System.err﹕ at com.google.android.gms.auth.GoogleAuthUtil.getToken(Unknown Source)
10-06 03:05:11.634 1876-2140/com.infotech.palmtree.proxybeacon W/System.err﹕ at com.google.android.gms.auth.GoogleAuthUtil.getToken(Unknown Source)
10-06 03:05:11.634 1876-2140/com.infotech.palmtree.proxybeacon W/System.err﹕ at com.infotech.palmtree.proxybeacon.MainActivity.fetchToken(MainActivity.java:106)
10-06 03:05:11.634 1876-2140/com.infotech.palmtree.proxybeacon W/System.err﹕ at com.infotech.palmtree.proxybeacon.MainActivity.access$100(MainActivity.java:24)
10-06 03:05:11.634 1876-2140/com.infotech.palmtree.proxybeacon W/System.err﹕ at com.infotech.palmtree.proxybeacon.MainActivity$GetTokenTask.doInBackground(MainActivity.java:87)
10-06 03:05:11.634 1876-2140/com.infotech.palmtree.proxybeacon W/System.err﹕ at com.infotech.palmtree.proxybeacon.MainActivity$GetTokenTask.doInBackground(MainActivity.java:82)
10-06 03:05:11.634 1876-2140/com.infotech.palmtree.proxybeacon W/System.err﹕ at android.os.AsyncTask$2.call(AsyncTask.java:292)
10-06 03:05:11.634 1876-2140/com.infotech.palmtree.proxybeacon W/System.err﹕ at java.util.concurrent.FutureTask.run(FutureTask.java:237)
10-06 03:05:11.634 1876-2140/com.infotech.palmtree.proxybeacon W/System.err﹕ at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
10-06 03:05:11.634 1876-2140/com.infotech.palmtree.proxybeacon W/System.err﹕ at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
10-06 03:05:11.634 1876-2140/com.infotech.palmtree.proxybeacon W/System.err﹕ at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
10-06 03:05:11.634 1876-2140/com.infotech.palmtree.proxybeacon W/System.err﹕ at java.lang.Thread.run(Thread.java:818)
10-06 03:05:11.635 1876-2140/com.infotech.palmtree.proxybeacon I/Timeline﹕ Timeline: Activity_launch_request id:com.google.android.gms time:6855445
10-06 03:05:11.722 1876-1876/com.infotech.palmtree.proxybeacon I/Timeline﹕ Timeline: Activity_launch_request id:com.google.android.gms time:6855532

最佳答案

错误是不言自明的。这:UserRecoverableAuthException: DeviceManagementSyncDisabled 似乎是根本原因。 (所述错误的 Explanation)

我假设您需要在您的测试设备上启用同步,这应该可以解决该错误。

PS:日志中出现以下文字是因为Auth失败。

关于android - AsyncTask 在尝试获取 token 时触发错误消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32963514/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com