Merge "Fix potential NPE when saving/deleting Autofill profile."
diff --git a/src/com/android/browser/AutoFillSettingsFragment.java b/src/com/android/browser/AutoFillSettingsFragment.java
index 141de34..04f45b5 100644
--- a/src/com/android/browser/AutoFillSettingsFragment.java
+++ b/src/com/android/browser/AutoFillSettingsFragment.java
@@ -116,16 +116,21 @@
         mHandler = new Handler() {
             @Override
             public void handleMessage(Message msg) {
+                Context c = getActivity();
                 switch (msg.what) {
                 case PROFILE_SAVED_MSG:
-                    Toast.makeText(getActivity(), R.string.autofill_profile_successful_save,
-                            Toast.LENGTH_SHORT).show();
-                    closeEditor();
+                    if (c != null) {
+                        Toast.makeText(c, R.string.autofill_profile_successful_save,
+                                Toast.LENGTH_SHORT).show();
+                        closeEditor();
+                    }
                     break;
 
                 case PROFILE_DELETED_MSG:
-                    Toast.makeText(getActivity(), R.string.autofill_profile_successful_delete,
-                            Toast.LENGTH_SHORT).show();
+                    if (c != null) {
+                        Toast.makeText(c, R.string.autofill_profile_successful_delete,
+                                Toast.LENGTH_SHORT).show();
+                    }
                     break;
                 }
             }