Potential fix for a monkey-related NPE
Cache the content resolver so that async callbacks, events can continue to get the cntent resolver when detached from the activity. This should help with stability. Bug: 8005271 Change-Id: Ia566bc312ce678b438004bdf4ed7537ac1604608
This commit is contained in:
@@ -20,6 +20,7 @@ import android.app.Dialog;
|
||||
import android.app.DialogFragment;
|
||||
import android.app.Fragment;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
@@ -48,6 +49,9 @@ public class SettingsPreferenceFragment extends PreferenceFragment implements Di
|
||||
|
||||
private String mHelpUrl;
|
||||
|
||||
// Cache the content resolver for async callbacks
|
||||
private ContentResolver mContentResolver;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle icicle) {
|
||||
super.onCreate(icicle);
|
||||
@@ -104,7 +108,11 @@ public class SettingsPreferenceFragment extends PreferenceFragment implements Di
|
||||
* Returns the ContentResolver from the owning Activity.
|
||||
*/
|
||||
protected ContentResolver getContentResolver() {
|
||||
return getActivity().getContentResolver();
|
||||
Context context = getActivity();
|
||||
if (context != null) {
|
||||
mContentResolver = context.getContentResolver();
|
||||
}
|
||||
return mContentResolver;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user