Question

I'm looking for the answer since the begining of the day and I still don't know what to do! To explain the problem: My application uses GTasks API. To do this, the user MUST have a google account. I have two ways to check that:

  1. I instantiate an Account manager and look for "com.google" accounts if there are no such accounts
  2. I launch a webview on which the user logs on Google and accepts to use the API.

Then, I have to synchronize my application with GTask. From the information extracted from the webview, I tried to create a "com.google" account using the AccountManager but I always have the error "Caller UID is different...". I know that the problem should come from "account-authenticator" because the "accountType" has to be the same in the XML file and in the app but I think that's not the case because when I use a different account type, it perfectly works (but I can't obtain an authToken from GTask).

So, here is my code:

Authenticator.xml:

<account-authenticator xmlns:android="http://schemas.android.com/apk/res/android"
    android:accountType="com.google"
    android:icon="@drawable/miniicon"
    android:smallIcon="@drawable/miniicon"
    android:label="@string/app_name"
    android:accountPreferences="@xml/preferences"
 />

Definition of the account type:

 public class AuthenticationService extends Service {
     public static final String ACCOUNT_TYPE = "com.google";

How I use it in my class:

 AccountManager manager = AccountManager.get(activity);

 final Account account = new Account(login, AuthenticationService.ACCOUNT_TYPE);
 manager.addAccountExplicitly(account, password, new Bundle());

When I use "com.plop" or anaything else instead of "com.google", it works really fine.

So, my two questions are: 1. Can I use the "com.google" account type? 2. Is that normal that I can't obtain my authToken using something else than "com.google" (knowing that the account used is still a Google account, it's just not set like that on Android) ?

Thx in advance for your help and, please, forgive me if the answer was on the site!

Was it helpful?

Solution

I answered my own question: that's not possible the way I wanted to. You have to use the "addAccount" function using a "com.google" account type. This will result in popping the account creation activity used by the android system. Then, everything is fine using GTasks API.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top