I have code and worked for Exit Application with this code:
class Example extends Dialog {
@Override
public void dismiss() {
super.dismiss();
if (isForceExists != false) {
int id = android.os.Process.myPid();
android.os.Process.killProcess(id);
}
}
}
But.. when I want to running event other before exit application not working (skip event).
class ExampleActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
Example exDialog = new Example();
exDialog.setDismissListener(new OnDismissListener() {
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
builder.setTitle("Exit Application")
.setMessage("Thank you for using this application, happy nice day ^_^")
.show();
});
}
}
I want to run event dismiss or wait progress task before exit application, How to do? But it is script force exit application without running event before it?
You should handle the event logic in your Example class or within the ExampleActivity itself, rather than trying to run the event within the onCreate method of ExampleActivity when the dialog is shown.
Modify your Example class to include a callback for the dismissal event:
Modify your ExampleActivity to implement the OnDismissListener interface and override its onDismiss method to execute your desired event before exiting the application:
This approach ensures that your event runs before the application exits when you dismiss the dialog.