I'm getting an exception when I try to pop up an alert dialog from within the onOptionsItemSelected method of an Activity. The exception looks like this:
W/WindowManager( 57): Attempted to add window with non-application token WindowToken{43c4d3b0 token=null}. Aborting. I pasted the same code into a button's onClick method and it worked fine. Any ideas? Here's the code: AlertDialog alertDialog = new AlertDialog.Builder(getApplicationContext()).create(); alertDialog.setTitle(R.string.confirmClear); alertDialog.setMessage(getString(R.string.areYouSure)); alertDialog.setButton(AlertDialog.BUTTON_POSITIVE, getString(R.string.yes), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { /* * This is where we clear all the events from the database. */ // do something } }); alertDialog.setButton(AlertDialog.BUTTON_NEGATIVE, getString(R.string.no), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // don't do anything return; } }); alertDialog.show(); -- You received this message because you are subscribed to the Google Groups "Android Beginners" group. NEW! Try asking and tagging your question on Stack Overflow at http://stackoverflow.com/questions/tagged/android To unsubscribe from this group, send email to android-beginners+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en