private void showDialog(CharSequence messageId) {mDialog = new AlertDialog.Builder(getApplicationContext()).setMessage(messageId).setPositiveButton(android.R.string.ok,new DialogInterface.OnClickListener() {@Overridepublic void onClick(DialogInterface dialog, int whichButton) {mDialog.dismiss();}}).create();mDialog.show();}
A/SystemServer(2093): android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application
--
You received this message because you are subscribed to the Google Groups "android-platform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-platfo...@googlegroups.com.
To post to this group, send email to android-...@googlegroups.com.
Visit this group at http://groups.google.com/group/android-platform.
For more options, visit https://groups.google.com/groups/opt_out.
--
You received this message because you are subscribed to the Google Groups "android-platform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-platfo...@googlegroups.com.
To post to this group, send email to android-...@googlegroups.com.
Visit this group at http://groups.google.com/group/android-platform.
For more options, visit https://groups.google.com/groups/opt_out.
mDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ERROR);
mDialog.getWindow().getAttributes().privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_SHOW_FOR_ALL_USERS;
public void showSettingsAlert(){
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(MainActivity.this);
AlertDialog alertDialog = alertDialogBuilder.create();
alertDialogBuilder.setMessage("GPS is not enabled. Do you want to go to settings menu?");
alertDialog.setTitle("GPS is settings");
// On pressing Settings button
alertDialog.setPositiveButton("Settings", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,int which) {
Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
startActivity(intent);
}
});
// on pressing cancel button
alertDialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
});
// Showing Alert Message
alertDialog.show();
}