aboutsummaryrefslogtreecommitdiffstats
path: root/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/KeychainApplication.java
diff options
context:
space:
mode:
authorDominik Schürmann <dominik@dominikschuermann.de>2014-08-21 11:36:47 +0200
committerDominik Schürmann <dominik@dominikschuermann.de>2014-08-21 11:36:47 +0200
commit3c46c3c2dfd4ec6ec8b91eb43246c7d579f9b95d (patch)
tree09bea49057386890b5734c1d1a9083967c7aaa24 /OpenKeychain/src/main/java/org/sufficientlysecure/keychain/KeychainApplication.java
parent0c1e65bc8bbfed59d299e2f0ca7a6a30eef22664 (diff)
downloadopen-keychain-3c46c3c2dfd4ec6ec8b91eb43246c7d579f9b95d.tar.gz
open-keychain-3c46c3c2dfd4ec6ec8b91eb43246c7d579f9b95d.tar.bz2
open-keychain-3c46c3c2dfd4ec6ec8b91eb43246c7d579f9b95d.zip
Add account only on jelly bean and above
Diffstat (limited to 'OpenKeychain/src/main/java/org/sufficientlysecure/keychain/KeychainApplication.java')
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/KeychainApplication.java20
1 files changed, 12 insertions, 8 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/KeychainApplication.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/KeychainApplication.java
index aee6a5d70..37af95e28 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/KeychainApplication.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/KeychainApplication.java
@@ -25,6 +25,7 @@ import android.content.Context;
import android.content.Intent;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
+import android.os.Build;
import android.os.Environment;
import android.provider.ContactsContract;
@@ -111,14 +112,17 @@ public class KeychainApplication extends Application {
}
public static void setupAccountAsNeeded(Context context) {
- AccountManager manager = AccountManager.get(context);
- Account[] accounts = manager.getAccountsByType(Constants.ACCOUNT_TYPE);
- if (accounts == null || accounts.length == 0) {
- Account account = new Account(Constants.ACCOUNT_NAME, Constants.ACCOUNT_TYPE);
- if (manager.addAccountExplicitly(account, null, null)) {
- ContentResolver.setIsSyncable(account, ContactsContract.AUTHORITY, 1);
- } else {
- Log.e(Constants.TAG, "Adding account failed!");
+ // only enabled for Jelly Bean because we need some newer methods in our sync adapter
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
+ AccountManager manager = AccountManager.get(context);
+ Account[] accounts = manager.getAccountsByType(Constants.ACCOUNT_TYPE);
+ if (accounts == null || accounts.length == 0) {
+ Account account = new Account(Constants.ACCOUNT_NAME, Constants.ACCOUNT_TYPE);
+ if (manager.addAccountExplicitly(account, null, null)) {
+ ContentResolver.setIsSyncable(account, ContactsContract.AUTHORITY, 1);
+ } else {
+ Log.e(Constants.TAG, "Adding account failed!");
+ }
}
}
}