How to trigger Account Manager to add new account from application
I am trying to extend the SampleSync application. After I install the app, I can go to s开发者_开发百科ettings -> accounts & sync -> add account to add an account. However, if I want to check from my Application code and want to trigger AccountManager to add a new account directly, what should be the best way?
Ok, finally I got it working,
You can actually activate the AccountManager to add an account:
final AccountManager accountMgr = AccountManager.get(Main.this);
accountMgr.addAccount(Constants.ACCOUNT_TYPE, Constants.AUTHTOKEN_TYPE, null, null, Main.this, null, null);
精彩评论