Add account automatically

前端 未结 3 1635
不知归路
不知归路 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:21

    There is Android AtLeap library which contains helper classes to use Account Authenticator. Have a look at it https://github.com/blandware/android-atleap

    0 讨论(0)
  • 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);
    
    0 讨论(0)
  • 2020-12-16 08:42

    Don't you have to add to the following code posted by Evan Elliott :

    Account account = new Account("Title", "com.package.nom");
    String password = "password";
    AccountManager accountManager = AccountManager.get(context);
    accountManager.addAccountExplicitly(account, password, null);
    

    The following: ?

    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"
     />
    

    and permissions?

    0 讨论(0)
提交回复
热议问题