Untitled
public class MyActivity extends AppCompatActivity { // Method to show your dialog private void showDialog() { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("My Dialog") .setMessage("This is a dialog message.") .setPositiveButton("OK", (dialog, which) -> { // Handle positive button click }) .setNegativeButton("Cancel", (dialog, which) -> { // Handle negative button click }); AlertDialog dialog = builder.create(); dialog.show(); } // Override onDestroy method to detect when the dialog is being destroyed @Override protected void onDestroy() { super.onDestroy(); // Show another dialog here if needed // showDialog(); } }
Leave a Comment