Add account automatically

前端 未结 3 1640
不知归路
不知归路 2020-12-16 07:59

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\

3条回答
  •  臣服心动
    2020-12-16 08:39

    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);
    

提交回复
热议问题