I am using following code to add account into Account list
final AccountManager accountMgr = AccountManager.get(this.getApplicationContext());
Account ac = new Account("my.id","com.google");
try{
accountMgr.addAccountExplicitly(ac, "password", null);}
catch(Exception e){
String str = e.getLocalizedMessage();
Log.e("err",str);
}
but getting following error everytime: 'caller uid 10066 is different than the authenticator's uid'
The following stackoverflow question seems to deal with the issue:
SecurityException: caller uid XXXX is different than the authenticator's uid
The article it links to ( http://loganandandy.tumblr.com/post/613041897/caller-uid-is-different ) explains the whole thing, though it took me a minute to realise what part of my code the last xml snippet was referring to.
I ended up storing my account type and auth token type in my strings.xml and referencing them in the authenticator.xml and code as needed.
精彩评论