summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Murdoch <benm@google.com>2011-08-11 10:39:59 +0100
committerBen Murdoch <benm@google.com>2011-08-11 10:42:57 +0100
commit381280d263748055bda5df3bf7d1d10b65b85f5c (patch)
tree1a6709bcccaa500205105490f7fc14e3299d0781
parent864a2200268f9a9fc3edfad1f4ac1bab60d4fab1 (diff)
downloadpackages_apps_Browser-381280d263748055bda5df3bf7d1d10b65b85f5c.zip
packages_apps_Browser-381280d263748055bda5df3bf7d1d10b65b85f5c.tar.gz
packages_apps_Browser-381280d263748055bda5df3bf7d1d10b65b85f5c.tar.bz2
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
-rw-r--r--src/com/android/browser/AutoFillSettingsFragment.java15
1 files changed, 10 insertions, 5 deletions
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 @@ public class AutoFillSettingsFragment extends Fragment {
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;
}
}