Fixes crash when clearing history
Bug: 3253556
The dialog to clear the history was trying to reference the fragment
creating it, however that fragment was being destroyed. Fixed this
by hanging on to the ContentResolver instead of trying to call getActivity()
Change-Id: Ie46fd4cc34e7034ce9a21a6b8856041f8d350f17
diff --git a/src/com/android/browser/BrowserHistoryPage.java b/src/com/android/browser/BrowserHistoryPage.java
index 2fdfedd..e9db667 100644
--- a/src/com/android/browser/BrowserHistoryPage.java
+++ b/src/com/android/browser/BrowserHistoryPage.java
@@ -22,6 +22,7 @@
import android.app.Fragment;
import android.app.LoaderManager.LoaderCallbacks;
import android.content.ClipboardManager;
+import android.content.ContentResolver;
import android.content.Context;
import android.content.CursorLoader;
import android.content.DialogInterface;
@@ -221,6 +222,7 @@
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.clear_history_menu_id:
+ final ContentResolver resolver = getActivity().getContentResolver();
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity())
.setTitle(R.string.clear)
.setMessage(R.string.pref_privacy_clear_history_dlg)
@@ -230,7 +232,7 @@
@Override
public void onClick(DialogInterface dialog, int which) {
if (which == DialogInterface.BUTTON_POSITIVE) {
- Browser.clearHistory(getActivity().getContentResolver());
+ Browser.clearHistory(resolver);
mCallbacks.onRemoveParentChildRelationships();
}
}