0

I have below code to display dialog box. Our requirement is user has too update app before login to the app.

new AlertDialog.Builder(LoginSlider.this)
    .setTitle("Update is Available!")
    .setMessage("Please update your app to use new features")
    .setPositiveButton("Update now", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
               final String appPackageName = getPackageName();
               startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + appPackageName)));
               }
            })
    .setIcon(android.R.drawable.ic_dialog_alert)
    .show();

enter image description here

When I click out side of the dialog box. it gets disappear. I don't want that. How can I do this?

RNK
  • 5,582
  • 11
  • 65
  • 133
  • 1
    Does [this answer](http://stackoverflow.com/a/19064968/4771017) help? _"[...]to prevent dismiss dialog box on outside touch use this `dialog.setCanceledOnTouchOutside(false);`"_ Though also check [this post](http://stackoverflow.com/questions/13526690/why-setcanceledontouchoutsidefalse-doesnt-work-in-alert-builder) for a case where it may not work as expected. – CubeJockey May 26 '15 at 16:59
  • How can I use this in my code? I don't have dialog object – RNK May 26 '15 at 17:01
  • @Trobbins: when I tried to use both methods (setCancelable(false) and setCanceledOnTouchOutside(false)). It's giving me error like: can not resolve method for one method – RNK May 26 '15 at 17:08
  • (for others:) My mistake, `.setCanceledOnTouchOutside(boolean b)` is not a part of the [AlertDialog.Builder](http://developer.android.com/reference/android/app/AlertDialog.Builder.html) API, however, `setCancelable(boolean b)` is – CubeJockey May 26 '15 at 17:16
  • yeah.. What should I use instead of that method? I need to prevent outside touch as well. – RNK May 26 '15 at 17:17

0 Answers0