mirror of
https://github.com/etesync/android
synced 2025-01-11 08:10:58 +00:00
Create an AndroidCompat class to wrap around Android oddities.
As part of it, move removeAccount to that class.
This commit is contained in:
parent
de6a124bf2
commit
c81ba0cddb
@ -33,6 +33,7 @@ import android.support.v4.os.OperationCanceledException;
|
||||
import com.etesync.syncadapter.App;
|
||||
import com.etesync.syncadapter.model.CollectionInfo;
|
||||
import com.etesync.syncadapter.model.JournalEntity;
|
||||
import com.etesync.syncadapter.utils.AndroidCompat;
|
||||
import com.etesync.syncadapter.utils.Base64;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
@ -143,12 +144,7 @@ public class LocalAddressBook extends AndroidAddressBook implements LocalCollect
|
||||
|
||||
public void delete() {
|
||||
AccountManager accountManager = AccountManager.get(context);
|
||||
if (Build.VERSION.SDK_INT >=
|
||||
Build.VERSION_CODES.LOLLIPOP_MR1) {
|
||||
accountManager.removeAccountExplicitly(account);
|
||||
} else {
|
||||
accountManager.removeAccount(account, null, null);
|
||||
}
|
||||
AndroidCompat.removeAccount(accountManager, account);
|
||||
}
|
||||
|
||||
public LocalAddressBook(Context context, Account account, ContentProviderClient provider) {
|
||||
|
@ -0,0 +1,16 @@
|
||||
package com.etesync.syncadapter.utils;
|
||||
|
||||
import android.accounts.Account;
|
||||
import android.accounts.AccountManager;
|
||||
import android.os.Build;
|
||||
|
||||
public class AndroidCompat {
|
||||
public static void removeAccount (AccountManager accountManager, Account account) {
|
||||
if (Build.VERSION.SDK_INT >=
|
||||
Build.VERSION_CODES.LOLLIPOP_MR1) {
|
||||
accountManager.removeAccountExplicitly(account);
|
||||
} else {
|
||||
accountManager.removeAccount(account, null, null);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user