android - 以编程方式设置 Google 手机帐户

标签 android accountmanager google-account

我有兴趣在手机上以编程方式添加和设置具有给定用户名和密码的硬编码 Google 帐户,而无需任何用户干预。

我试过用

AccountsManager.addAccountExplicitly(newAccount("xxxxxx@gmail.com","com.google",password,null) 

它适用于所有 accountsType 除了 com.google accountsType 抛出“uid not matching authenticator id”异常。

我已经遵循了这个特定线程中给出的所有修复错误的建议,但没有用,com.google 帐户类型的错误仍然存​​在

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

我尝试的另一种替代方法是使用 samplesyncadapter 代码,它工作得很好,身份验证部分是在 NetworkUtilities 文件中完成的,我认为需要将其更改为Google 帐户 clientlogin

无论如何,这是否可以在无需用户干预验证码的情况下直接执行?

最佳答案

好的,几个月后,我设法解决了这个问题。可能对某人有帮助。

该解决方案不是通用的,而是针对模拟器/设备 LCD 特性和丑陋的。

我使用 MonkeyRunner 在指定的屏幕坐标处发出触摸、按下和按键事件,以到达主页->应用程序->设置->帐户和同步->添加帐户->Google->下一步->登录等

可以在此处找到有关 MonkeyRunner 的更多详细信息

http://developer.android.com/tools/help/monkeyrunner_concepts.html

关于android - 以编程方式设置 Google 手机帐户,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12547405/

相关文章:

android - 内部错误 : retry receiver class not set yet

android - 如何在没有 SyncAdapter 的情况下在 Android 上实现帐户

android - 如何显式添加具有广告帐户的帐户?

android - 获取主 Gmail 帐户状态

android - 是否可以将 Google Prompt 用于我自己的应用程序?

android - 缩放 9 补丁图像的脚本

android - 通过 Intent 传递后对象列表为空。对象类实现 Parcelable 接口(interface)

youtube - 创建自动的YouTube观看机器?

android - 恢复备份消息,对话时间不正确

android - 如何从使用其他应用程序创建的自定义帐户调用 accountManager.getUserData?