rapidoodle
rapidoodle

Reputation: 350

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

Upvotes: 0

Views: 136

Answers (1)

Koh
Koh

Reputation: 1570

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. 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.
  2. Uninstall the version of your Glassware still on your device (adb uninstall <package name>).
  3. Turn on the Glassware on MyGlass. Wait for Glass to sync and install it.
  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.

Upvotes: 1

Related Questions