Index: src/org/adblockplus/sbrowser/contentblocker/ContentBlockerContentProvider.java |
diff --git a/src/org/adblockplus/sbrowser/contentblocker/ContentBlockerContentProvider.java b/src/org/adblockplus/sbrowser/contentblocker/ContentBlockerContentProvider.java |
index 15bf7b49d9a924a7d5c03890bbc509473ae0cf9c..7a6008e6e99c4e1bbf8224038ef75b5c1e3e8100 100644 |
--- a/src/org/adblockplus/sbrowser/contentblocker/ContentBlockerContentProvider.java |
+++ b/src/org/adblockplus/sbrowser/contentblocker/ContentBlockerContentProvider.java |
@@ -49,12 +49,25 @@ public class ContentBlockerContentProvider extends ContentProvider implements |
return null; |
} |
+ private static boolean getBooleanPref(final SharedPreferences prefs, final String key, |
+ final boolean defValue) |
+ { |
+ try |
+ { |
+ return prefs.getBoolean(key, defValue); |
+ } |
+ catch (final Throwable t) |
+ { |
+ return defValue; |
+ } |
+ } |
+ |
private void setApplicationActivated() |
{ |
final SharedPreferences prefs = PreferenceManager |
- .getDefaultSharedPreferences(this.getContext()); |
+ .getDefaultSharedPreferences(this.getContext().getApplicationContext()); |
final String key = this.getContext().getString(R.string.key_application_activated); |
- final boolean applicationActived = prefs.getBoolean(key, false); |
+ final boolean applicationActived = getBooleanPref(prefs, key, false); |
if (!applicationActived) |
{ |
prefs.edit() |
@@ -91,7 +104,7 @@ public class ContentBlockerContentProvider extends ContentProvider implements |
@Override |
public boolean onCreate() |
{ |
- EngineService.startService(this.getContext(), this); |
+ EngineService.startService(this.getContext().getApplicationContext(), this); |
return true; |
} |