-1

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.

egente
  • 3
  • 5
  • you should learn android basics first: what is an Activity and how to start it(and why i should never call new operator on class which extends Activity class) then learn how to use dialogs on android platforms then learn how to use shared preferences ... before that every answer is is like trying to describe a rainbow to a blind man ... – Selvin Aug 26 '14 at 15:03

1 Answers1

0

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);
}
MartinCR
  • 658
  • 6
  • 7