MainActivity Class, exit button click event:
public void onClick(View v) {
CustomDialog cd = new CustomDialog();
dialog = new Dialog(this);
cd.runConfirmationDialog(dialog, R.layout.custommessage,
R.id.d_tittle, "Exit", R.id.d_text, "Close Application",
R.id.btn_no, R.id.btn_yes, this);
}
CustomDialog Class:
public class CustomDialog extends Activity {
void runConfirmationDialog(final Dialog dialog, int customLayoutID,int titleID, String title, int messageID, String message, int buttonCancelID,
int buttonOkeyID, final CustomDialogMethods main) {
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(customLayoutID);
}
void show(){
}
Now, i want create Custom Dialog with runConfirmationDialog methods when application first time run. After i want show Dialog Box with only simple Show Methods in another classes.
Which way to best for it?
Thanks.
I think the best way to do this is to save on SharedPreferences a boolean that indicates if the dialog has been shown:
public static void setFirstRunDialogShown(Context context, boolean value) {
Editor editor = context.getSharedPreferences(SETTINGS_NAME, Context.MODE_PRIVATE).edit();
editor.putBoolean(DIALOG_SHOWN, value);
editor.apply();
}
public static boolean isFirstRunDialogShown(Context context) {
return context.getSharedPreferences(SETTINGS_NAME, Context.MODE_PRIVATE).getBoolean(DIALOG_SHOWN, false);
}