ERROR/AndroidRuntime: android.view.WindowManager$BadTokenException: Unable to add window — token null is not for an application


Probably given a context instead of a activity, for example in
DatePickerDialog datePicker = new DatePickerDialog(
appActivity, (OnDateSetListener) this, calendar
.get(Calendar.YEAR), calendar
.get(Calendar.MONTH), calendar
.get(Calendar.DAY_OF_MONTH));

Compiler will not report a error for
private Context context = getApplicationContext() ;
private Activity appContext = context

Probably given a context instead of a activity, for example in
DatePickerDialog datePicker = new DatePickerDialog(
appActivity, (OnDateSetListener) this, calendar
.get(Calendar.YEAR), calendar
.get(Calendar.MONTH), calendar
.get(Calendar.DAY_OF_MONTH));

Compiler will not report a error for
private Context context = getApplicationContext() ;
private Activity appContext = context

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s