简体   繁体   English

使用GDK检索Google Glass中的帐户

[英]Retrieving account in google glass using GDK

My glassware is requiring user account credentials so I use this to authenticate a user. 我的玻璃器皿需要用户帐户凭据,因此我使用来验证用户身份。 I'm successfully inserting user account with this . 我已经成功地为此插入了用户帐户。 However when I'm retrieving the account, i'm getting 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)

I already did the same solution came from Alain here . 我已经做了同样的解决方案从阿兰来到这里 But still getting the same error. 但是仍然出现相同的错误。

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);
        }
    }

Sorry for the delay. 抱歉耽搁了。 One reason could be that you used a different certificate when you submitted your APK for review and the one you use for testing. 原因之一可能是,您提交APK进行审核时使用的证书与用于测试的证书不同。 Here's what you could try to do: 您可以尝试执行以下操作:

  1. Turn off your Glassware on MyGlass and wait for Glass to sync and remove the Glassware from the device. 关闭MyGlass上的Glassware,然后等待Glass同步并从设备中删除Glassware。
  2. Uninstall the version of your Glassware still on your device ( adb uninstall <package name> ). 卸载仍在设备上的Glassware版本( adb uninstall <package name> )。
  3. Turn on the Glassware on MyGlass. 打开MyGlass上的玻璃器皿。 Wait for Glass to sync and install it. 等待Glass同步并安装它。
  4. This should already be working. 这应该已经可以了。 If you have new versions, you can still deploy locally, but make sure to use the same certificate/key. 如果您有新版本,则仍然可以在本地部署,但是请确保使用相同的证书/密钥。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM