1

我正在使用以下代码将帐户添加到帐户列表中

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

但每次都会出现以下错误:'caller uid 10066 is different than the authenticationator's uid'

4

1 回答 1

3

以下stackoverflow问题似乎可以解决这个问题:

SecurityException: caller uid XXXX is different than the authenticationator's uid

它链接到的文章(http://loganandandy.tumblr.com/post/613041897/caller-uid-is-different)解释了整个事情,尽管我花了一分钟才意识到我的代码的哪一部分是最后一个 xml 片段指的是。

我最终将我的帐户类型和身份验证令牌类型存储在我的 strings.xml 中,并根据需要在 authenticationator.xml 和代码中引用它们。

于 2011-11-15T04:34:14.833 回答