Reputation: 65
I am trying to close the system dialog but the dialog has only "ok" button and cannot cancelable on back button. I tried two ways. first in broadcast
public void onReceive(Context context, Intent intent) {
Intent closeDialog = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
context.getApplicationContext().sendBroadcast(closeDialog);}
second
@Override
public void onWindowFocusChanged(boolean isTrue) {
super.onWindowFocusChanged(isTrue);
if (!isTrue){
Intent closeDialog = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
sendBroadcast(closeDialog);
}
}
but no one works. Any help
Upvotes: 4
Views: 364
Reputation: 284
You can use something like this:
.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {public void onClick(DialogInterface dialog, int id) { // User cancelled the dialog}});
Upvotes: 1