【问题标题】:Trying to add a gmail account programmaticaly in android but getting error "caller uid 10040 is different than the authenticator's uid"尝试在 android 中以编程方式添加 gmail 帐户,但出现错误“调用者 uid 10040 与身份验证器 uid 不同”
【发布时间】:2012-09-11 12:04:55
【问题描述】:

在 android 中有一个 emial 应用程序允许添加电子邮件帐户。如何以编程方式在该应用程序中添加 gmail 帐户?

我使用了这个链接Add account automatically 但是 得到 SecurityException "caller uid 10040 is different than the authenticator's uid"。

我使用了那个代码

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

其中“com.example.addaccount.account”是我的应用程序的包名,我在名为 xml 的文件夹中添加了authenticator.xml 文件,包名相同 android:accountType="com.example.addaccount.account" .

但我收到错误消息“调用者 uid 10043 与验证者的 uid 不同”。谁能告诉我,我错过了什么?我刚刚添加了 xml 文件并编写了该代码来添加帐户,我是否需要以某种方式引用该 xml?

【问题讨论】:

    标签: android gmail accountmanager google-account


    【解决方案1】:

    此方法返回android market gmail账号

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

    在 manifest.xml 中也添加这个

             <uses-permission android:name="android.permission.GET_ACCOUNTS"/>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-04-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-12-31
      • 2019-04-18
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多