0

There is an emial application in android that allows to add email account. How can I add a gmail account in that application programmatically?

I used this link Add account automatically but got SecurityException "caller uid 10040 is different than the authenticator's uid".

I used that code with

        Account account = new Account("my id@gmail.com", "com.example.addaccount.account");

Where "com.example.addaccount.account" is package name of my application, and I added authenticator.xml file in a folder named xml, with same package name android:accountType="com.example.addaccount.account".

But I am getting error "caller uid 10043 is different than the authenticator's uid". Can any one please tell me, what am I missing? I just added the xml file and wrote that code to add account, do I need to refer to that xml somehow?

Community
  • 1
  • 1
blackfyre
  • 2,399
  • 5
  • 33
  • 57

1 Answers1

1

This method return the android market gmail account

public String getAccount(){
    String email=null;
    Account[] accounts = AccountManager.get(this).getAccountsByType("com.google");
    for (Account account : accounts) {
         email=accounts[0].toString(); 
    }
    return email;
}

also add this in manifest.xml

         <uses-permission android:name="android.permission.GET_ACCOUNTS"/>
Rajendra
  • 1,660
  • 14
  • 17