AlertDialog alertDialog = new AlertDialog.Builder(context) .setTitle("Title") .setMessage("Message") .setPositiveButton("OK", null) .create(); alertDialog.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialogInterface) { // Do something when the AlertDialog is shown } }); alertDialog.show();In this example, an AlertDialog is created and a listener is set using the setOnShowListener method. When the AlertDialog is shown, the onShow method is called and any actions specified in the method will be executed. The android.app package contains the classes for the Android application model.