我的应用程序需要同步服务器中的一些数据。我添加了必要的类(类似于SampleSyncAdapter),现在我可以通过“设置/同步和帐户”添加帐户。 但是我希望在安装应用程序后立即添加我的帐户和工作同步(我不希望用户在设置中进行任何手动更改)。这个怎么做?自动添加帐户
Q
自动添加帐户
3
A
回答
1
有一个Android AtLeap库,其中包含帮助程序类以使用Account Authenticator。看看它吧https://github.com/blandware/android-atleap
7
有点晚了,但...
Account account = new Account("Title", "com.package.nom");
String password = "password";
AccountManager accountManager = AccountManager.get(context);
accountManager.addAccountExplicitly(account, password, null);
1
你没有添加到发布的埃文埃利奥特下面的代码:
Account account = new Account("Title", "com.package.nom");
String password = "password";
AccountManager accountManager = AccountManager.get(context);
accountManager.addAccountExplicitly(account, password, null);
以下:
authenticator.xml
<?xml version="1.0" encoding="utf-8"?>
<account-authenticator xmlns:android="http://schemas.android.com/apk/res/android"
android:accountType="@string/account_type"
android:icon="@drawable/icon_hdpi"
android:smallIcon="@drawable/icon_hdpi"
android:label="@string/authenticator_label"
/>
和权限?
相关问题
- 1. 自动将新帐户添加到MediaWiki中的用户组
- 2. IPP添加帐户 - 帐户无效
- 3. 安装应用程序后自动添加帐户
- 4. (Drupal的twitter模块)添加用于登录的Twitter帐户,自动到该用户的Twitter帐户列表
- 5. Android帐户管理器 - 添加新帐户
- 6. Android帐户管理器从服务添加帐户
- 7. PERL - AD帐户添加 - 检查帐户是否存在
- 8. 使用Android的AccountManager添加一个自定义帐户
- 9. SharePoint 2007问题,用户自动添加
- 10. 自动将用户添加到撇号
- 11. 如何使用AddAccountExplicitly添加帐户?
- 12. 为ASPNET帐户添加权限
- 13. 在帐户菜单中添加项目
- 14. 将Windows帐户添加到SQL Server
- 15. 添加创建帐户框到主页
- 16. 通过代码添加谷歌帐户
- 17. 如何添加系统SIP帐户
- 18. AccountManager和OAuth - 如何添加帐户?
- 19. 将帐户对象添加到ArrayList
- 20. SecurityException在尝试添加帐户时
- 21. 通过PHP添加MySQL帐户
- 22. 以编程方式添加SIP帐户
- 23. 在Android上的活动中添加链接到Twitter帐户内
- 24. 活动的设置“添加帐户”选项,在Android
- 25. 添加一个动态的“帐户”链接?
- 26. 如何在“添加帐户”活动完成时得到通知
- 27. Concrete5用户帐户/添加用户页面上的动态选择列表
- 28. xp_cmdshell代理帐户被禁用自动
- 29. 自动登录到Laravel的帐户5
- 30. 自动发布到Facebook帐户
不幸的是,它看起来并不那么简单(它会失败,因为java.lang.SecurityException:caller uid 10007与认证者的uid不同)...请参阅Udinic的答案为更完整的答案。 (也许我错过了什么,但我真的不明白为什么这个答案被接受和upvoted?) – ben75
@ ben75显然是因为它在我发布它的时候工作。 –
如果您按照伊恩的建议,请考虑以下内容:https://stuff.mit.edu/afs/sipb/project/android/docs/training/id-auth/custom_auth.html#Security – Cray