@@ -41,16 +41,40 @@ public void setInAppBroswer(InAppBrowser browser) {
41
41
this .inAppBrowser = browser ;
42
42
}
43
43
44
- public void onBackPressed () {
44
+ public void onBackPressed () {
45
45
if (this .inAppBrowser == null ) {
46
46
this .dismiss ();
47
47
} else {
48
48
// better to go through the in inAppBrowser
49
49
// because it does a clean up
50
- if (this .inAppBrowser .hardwareBack () && this . inAppBrowser . canGoBack ()) {
50
+ if (this .inAppBrowser .canGoBack ()) {
51
51
this .inAppBrowser .goBack ();
52
- } else {
53
- this .inAppBrowser .closeDialog ();
52
+ } else {
53
+ AlertDialog .Builder alertDialogBuilder = new AlertDialog .Builder (context )
54
+ .setTitle ("Exit" )
55
+ .setMessage ("You are about to exit, are you sure?" )
56
+ .setPositiveButton ("Exit" , new DialogInterface .OnClickListener () {
57
+ public void onClick (DialogInterface dialog , int which ) {
58
+ if (inAppBrowser == null ) {
59
+ dismiss ();
60
+ } else {
61
+ // better to go through the in inAppBrowser
62
+ // because it does a clean up
63
+ if (inAppBrowser .hardwareBack () && inAppBrowser .canGoBack ()) {
64
+ inAppBrowser .goBack ();
65
+ } else {
66
+ inAppBrowser .closeDialog ();
67
+ }
68
+ }
69
+ }
70
+ })
71
+ .setNegativeButton ("Cancel" , new DialogInterface .OnClickListener () {
72
+ public void onClick (DialogInterface dialog , int which ) {
73
+ dialog .cancel ();
74
+ }
75
+ });
76
+ alertDialogBuilder .create ();
77
+ alertDialogBuilder .show ();
54
78
}
55
79
}
56
80
}
0 commit comments