am ddd75cb1: Merge "Fix NPE when showing Toast from system process." into jb-mr1.1-dev

* commit 'ddd75cb1ac225f8ffe8c78a5be8ceb589e0cda27':
  Fix NPE when showing Toast from system process.
This commit is contained in:
Craig Mautner
2012-12-05 12:27:58 -08:00
committed by Android Git Automerger

View File

@ -374,8 +374,11 @@ public class Toast {
// remove the old view if necessary // remove the old view if necessary
handleHide(); handleHide();
mView = mNextView; mView = mNextView;
mWM = (WindowManager)mView.getContext().getApplicationContext() Context context = mView.getContext().getApplicationContext();
.getSystemService(Context.WINDOW_SERVICE); 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 // We can resolve the Gravity here by using the Locale for getting
// the layout direction // the layout direction
final Configuration config = mView.getContext().getResources().getConfiguration(); final Configuration config = mView.getContext().getResources().getConfiguration();