static Account getSyncAccount(Context context, int syncInterval, int syncFlexTime) {
// Get an instance of the Android account manager
AccountManager accountManager =
(AccountManager) context.getSystemService(Context.ACCOUNT_SERVICE);
// Create the account type and default account
Account newAccount = new Account(context.getString(R.string.app_name),
context.getString(R.string.rnsb_sync_account_type));
// If the password doesn't exist, the account doesn't exist
if (null == accountManager.getPassword(newAccount)) {
/*
* Add the account and account type, no password or user data
* If successful, return the Account object, otherwise report an error.
*/
if (!accountManager.addAccountExplicitly(newAccount, "", null)) {
return null;
}
/*
* If you don't set android:syncable="true" in
* in your <provider> element in the manifest,
* then call ContentResolver.setIsSyncable(account, AUTHORITY, 1)
* here.
*/
onAccountCreated(newAccount, context, syncInterval, syncFlexTime);
}
return newAccount;
}
SyncAdapter.java 文件源码
java
阅读 41
收藏 0
点赞 0
评论 0
项目:react-native-sync-adapter
作者:
评论列表
文章目录