Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add account automatically

My application needs to synchronize some data from server. I added necessary classes (similarly to SampleSyncAdapter) now I can add account via "Settings/Sync and Accounts". But I want to have already added my account and working synchronization just after application is installed (I do not want user to do any manual changes in settings). How to do this?

like image 372
Solvek Avatar asked May 20 '26 22:05

Solvek


1 Answers

A bit late but...

Account account = new Account("Title", "com.package.nom");
String password = "password";
AccountManager accountManager = AccountManager.get(context);
accountManager.addAccountExplicitly(account, password, null);
like image 86
Ian Elliott Avatar answered May 22 '26 12:05

Ian Elliott