Code example for DialogInterface

Methods: cancel

0
                    .setTitle(R.string.modem_error)
                    .setMessage(R.string.device_rebooted_modem_error) 
                    .setNegativeButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                        @Override 
                        public void onClick(DialogInterface dialog, int which) {
                            dialog.cancel();
                        } 
                    }) 
                    .setOnCancelListener(new DialogInterface.OnCancelListener() {
                        @Override 
                        public void onCancel(DialogInterface dialog) {
                            finish();
                        } 
                    }) 
                    .create(); 
        } 
 
        return super.onCreateDialog(id, args);
    }