2010-12-10 30 views
1

我正试图扩展SampleSync应用程序。在我安装应用程序后,我可以进入设置 - >账户&同步 - >添加账户添加一个账户。但是,如果我想从我的应用程序代码中检查并希望触发AccountManager直接添加新帐户,那么最好的方法是什么?如何触发客户经理从应用程序添加新帐户

+0

http://stackoverflow.com/a/25890770/3282461 [这里](http://stackoverflow.com/a/25890770/3282461)代码的完整解决方案。 – Android 2014-09-17 12:44:20

+0

http://stackoverflow.com/a/25890770/3282461 看到这里......这是完整的代码和解决方案 – Android 2014-09-17 12:45:32

回答

5

好吧,我终于得到了它的工作,

实际上,你可以激活的AccountManager添加帐户:

final AccountManager accountMgr = AccountManager.get(Main.this); 
accountMgr.addAccount(Constants.ACCOUNT_TYPE, Constants.AUTHTOKEN_TYPE, null, null, Main.this, null, null); 
相关问题