diff options
author | Craig Mautner <cmautner@google.com> | 2012-12-05 09:49:57 -0800 |
---|---|---|
committer | Craig Mautner <cmautner@google.com> | 2012-12-05 09:57:44 -0800 |
commit | 54ae2f389cd0d9b9a558b5f61e096aec6215966b (patch) | |
tree | 866911726d0bc54bb718f6f75615fd59e410c086 /core | |
parent | 6c58b155c3bdde355adb03b191e43d8eec089fb2 (diff) | |
download | frameworks_base-54ae2f389cd0d9b9a558b5f61e096aec6215966b.zip frameworks_base-54ae2f389cd0d9b9a558b5f61e096aec6215966b.tar.gz frameworks_base-54ae2f389cd0d9b9a558b5f61e096aec6215966b.tar.bz2 |
Fix NPE when showing Toast from system process.
The system process has no ApplicationContext and consequently was
returning null. Use the base Context in these cases.
Bug 7673699 fixed.
Change-Id: Ie2ab856bb0baefff44775a12bef7802320f72656
Diffstat (limited to 'core')
-rw-r--r-- | core/java/android/widget/Toast.java | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/core/java/android/widget/Toast.java b/core/java/android/widget/Toast.java index 485bd37..1d85126 100644 --- a/core/java/android/widget/Toast.java +++ b/core/java/android/widget/Toast.java @@ -374,8 +374,11 @@ public class Toast { // remove the old view if necessary handleHide(); mView = mNextView; - mWM = (WindowManager)mView.getContext().getApplicationContext() - .getSystemService(Context.WINDOW_SERVICE); + Context context = mView.getContext().getApplicationContext(); + if (context == null) { + context = mView.getContext(); + } + mWM = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE); // We can resolve the Gravity here by using the Locale for getting // the layout direction final Configuration config = mView.getContext().getResources().getConfiguration(); |