Fix potential NPE when saving/deleting Autofill profile.

As the callback to display a toast confirmation to the user is
asynchronous there's a chance that the Fragment might be detached
when the callback is invoked. Guard against the potential NPE in
this case.

Bug: 5142413
Change-Id: Ic331e1ef3b738c5f2415b028da42c81f8f5e84d2
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;
                 }
             }