-2

I am not gonna tell you that I know how to do it or where to begin. Currently I am working on a small project in my company and I need to create an license agreement pop with two options. If you disagree with rules then app will be closed if you agree with rules, app will be opened.

Update:

Created a pop up that will be active on first run, agree and cancel options work. But when I click outside the pop up box it will be closed and I can use my app that shouldn't be the case

public void checkFirstRun() {
    boolean isFirstRun = getSharedPreferences("PREFERENCE", MODE_PRIVATE).getBoolean("isFirstRun", true);
    if (isFirstRun){

        new AlertDialog.Builder(this)
                .setTitle("Agreement")
                .setMessage("Text")
                .setPositiveButton("Agree",
                        new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                getSharedPreferences("PREFERENCE", MODE_PRIVATE)
                                        .edit()
                                        .putBoolean("isFirstRun", false)
                                        .apply();
                            }
                        })
                .setNegativeButton("Cencel",
                        new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                dialog.dismiss();
                                finish();
                            }
                        })
                .show();

    }
}
Markus Kauppinen
  • 3,025
  • 4
  • 20
  • 30
  • What have you tried and where are you stuck? I imagine a variety of Android tutorials and examples would be a great place to get started, and would likely include how to present a dialog to the user and respond to tapping on buttons. – David Jan 18 '19 at 14:17
  • I can't find no tutorials. Currently I am trying to figure it out how to create a view that won't allow to use app until you accept the rules – Lukas Šliužas Jan 18 '19 at 14:22
  • 1
    Have a look at [Modal dialog functionality using AlertDialog](https://stackoverflow.com/questions/8920661/modal-dialog-functionality-using-alertdialog). – Markus Kauppinen Jan 18 '19 at 15:35

1 Answers1

0

Then it's easy. First create a view (layout) and at the bottom put your widgets (2 buttons) for example open and close (agree/not) and by clicking the buttons, put for each : onClickListener with intents. That's it.

Elio Lako
  • 1,333
  • 2
  • 16
  • 26