mirror of
https://github.com/apache/cordova-android.git
synced 2025-02-01 02:12:58 +08:00
Add exit message.
This commit is contained in:
parent
e6aa64760e
commit
13f92b2b76
@ -201,7 +201,7 @@ public class App extends Plugin {
|
||||
* Exit the Android application.
|
||||
*/
|
||||
public void exitApp() {
|
||||
this.ctx.getActivity().finish();
|
||||
this.webView.postMessage("exit", null);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -237,6 +237,7 @@ public class CordovaWebViewClient extends WebViewClient {
|
||||
@Override
|
||||
public void onPageFinished(WebView view, String url) {
|
||||
super.onPageFinished(view, url);
|
||||
LOG.d(TAG, "onPageFinished(" + url + ")");
|
||||
|
||||
/**
|
||||
* Because of a timing issue we need to clear this history in onPageFinished as well as
|
||||
@ -286,7 +287,7 @@ public class CordovaWebViewClient extends WebViewClient {
|
||||
if (this.appView.callbackServer != null) {
|
||||
this.appView.callbackServer.destroy();
|
||||
}
|
||||
this.ctx.getActivity().finish();
|
||||
appView.postMessage("exit", null);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -337,6 +337,7 @@ public class DroidGap extends Activity implements CordovaInterface {
|
||||
this.init();
|
||||
}
|
||||
|
||||
// TODO @bc - background color doesn't work
|
||||
// If backgroundColor
|
||||
this.backgroundColor = this.getIntegerProperty("backgroundColor", Color.BLACK);
|
||||
LOG.e(TAG, "Setting background color=" + this.backgroundColor);
|
||||
@ -655,6 +656,7 @@ public class DroidGap extends Activity implements CordovaInterface {
|
||||
* The final call you receive before your activity is destroyed.
|
||||
*/
|
||||
public void onDestroy() {
|
||||
LOG.d(TAG, "onDestroy()");
|
||||
super.onDestroy();
|
||||
|
||||
if (this.appView != null) {
|
||||
@ -749,13 +751,6 @@ public class DroidGap extends Activity implements CordovaInterface {
|
||||
* End this activity by calling finish for activity
|
||||
*/
|
||||
public void endActivity() {
|
||||
this.finish();
|
||||
}
|
||||
|
||||
/**
|
||||
* Finish for Activity has been called.
|
||||
*/
|
||||
public void finish() {
|
||||
this.activityState = ACTIVITY_EXITING;
|
||||
super.finish();
|
||||
}
|
||||
@ -902,21 +897,25 @@ public class DroidGap extends Activity implements CordovaInterface {
|
||||
final DroidGap me = this;
|
||||
me.runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
AlertDialog.Builder dlg = new AlertDialog.Builder(me);
|
||||
dlg.setMessage(message);
|
||||
dlg.setTitle(title);
|
||||
dlg.setCancelable(false);
|
||||
dlg.setPositiveButton(button,
|
||||
new AlertDialog.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
dialog.dismiss();
|
||||
if (exit) {
|
||||
me.endActivity();
|
||||
try {
|
||||
AlertDialog.Builder dlg = new AlertDialog.Builder(me);
|
||||
dlg.setMessage(message);
|
||||
dlg.setTitle(title);
|
||||
dlg.setCancelable(false);
|
||||
dlg.setPositiveButton(button,
|
||||
new AlertDialog.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
dialog.dismiss();
|
||||
if (exit) {
|
||||
me.endActivity();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
dlg.create();
|
||||
dlg.show();
|
||||
});
|
||||
dlg.create();
|
||||
dlg.show();
|
||||
} catch (Exception e) {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -1077,6 +1076,9 @@ public class DroidGap extends Activity implements CordovaInterface {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
else if ("exit".equals(id)) {
|
||||
this.endActivity();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user