我的玻璃器皿需要用户帐户凭据,因此我使用this对用户进行身份验证。我已成功插入this的用户帐户。但是当我正在检索帐户时,我得到了这个
04-16 08:57:36.580: W/System.err(22726): android.accounts.OperationCanceledException
04-16 08:57:36.580: W/System.err(22726): at android.accounts.AccountManager$AmsTask.internalGetResult(AccountManager.java:1503)
04-16 08:57:36.580: W/System.err(22726): at android.accounts.AccountManager$AmsTask.getResult(AccountManager.java:1531)
04-16 08:57:36.580: W/System.err(22726): at android.accounts.AccountManager$AmsTask.getResult(AccountManager.java:1452)
04-16 08:57:36.580: W/System.err(22726): at info.genix.glass.MainActivity$1.run(MainActivity.java:108)
04-16 08:57:36.580: W/System.err(22726): at android.accounts.AccountManager$11.run(AccountManager.java:1427)
04-16 08:57:36.580: W/System.err(22726): at android.os.Handler.handleCallback(Handler.java:733)
04-16 08:57:36.580: W/System.err(22726): at android.os.Handler.dispatchMessage(Handler.java:95)
04-16 08:57:36.580: W/System.err(22726): at android.os.Looper.loop(Looper.java:149)
04-16 08:57:36.580: W/System.err(22726): at android.app.ActivityThread.main(ActivityThread.java:5045)
04-16 08:57:36.580: W/System.err(22726): at java.lang.reflect.Method.invokeNative(Native Method)
04-16 08:57:36.580: W/System.err(22726): at java.lang.reflect.Method.invoke(Method.java:515)
04-16 08:57:36.580: W/System.err(22726): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
04-16 08:57:36.580: W/System.err(22726): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
04-16 08:57:36.580: W/System.err(22726): at dalvik.system.NativeStart.main(Native Method)
我已经从Alain here那里得到了同样的解决方案。但仍然得到同样的错误。
CODE:
AccountManager accountManager = AccountManager.get(this);
// Use your Glassware's account type.
Account[] accounts = accountManager.getAccountsByType(ACCOUNT_TYPE);//Already approved by google
if (accounts != null && accounts.length > 0) {
Log.d(TAG, "MainActivity Account");
for (int i =0;i<accounts.length;i++)
{
accountManager.getAuthToken(accounts[i], "randomType", null, this, new AccountManagerCallback<Bundle>() {
public void run(AccountManagerFuture<Bundle> future) {
try {
Log.d(TAG, "MainActivity AccountManagerFuture");
String email = future.getResult().getString("email");
String uname = future.getResult().getString("uname");
Log.d(TAG, email+" "+dbname+" "+uname);
String token = future.getResult().getString(AccountManager.KEY_AUTHTOKEN);
Log.d("token","token :-"+ token);
// Use the token.
} catch (Exception e) {
// Handle exception.
e.printStackTrace();
}
}
}, null);
}
}
答案 0 :(得分:1)
抱歉延误。一个原因可能是您在提交APK以供审核时使用了不同的证书以及您用于测试的证书。以下是您可以尝试做的事情:
adb uninstall <package name>
)。