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.
|
* Exit the Android application.
|
||||||
*/
|
*/
|
||||||
public void exitApp() {
|
public void exitApp() {
|
||||||
this.ctx.getActivity().finish();
|
this.webView.postMessage("exit", null);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -237,6 +237,7 @@ public class CordovaWebViewClient extends WebViewClient {
|
|||||||
@Override
|
@Override
|
||||||
public void onPageFinished(WebView view, String url) {
|
public void onPageFinished(WebView view, String url) {
|
||||||
super.onPageFinished(view, 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
|
* 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) {
|
if (this.appView.callbackServer != null) {
|
||||||
this.appView.callbackServer.destroy();
|
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();
|
this.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO @bc - background color doesn't work
|
||||||
// If backgroundColor
|
// If backgroundColor
|
||||||
this.backgroundColor = this.getIntegerProperty("backgroundColor", Color.BLACK);
|
this.backgroundColor = this.getIntegerProperty("backgroundColor", Color.BLACK);
|
||||||
LOG.e(TAG, "Setting background color=" + this.backgroundColor);
|
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.
|
* The final call you receive before your activity is destroyed.
|
||||||
*/
|
*/
|
||||||
public void onDestroy() {
|
public void onDestroy() {
|
||||||
|
LOG.d(TAG, "onDestroy()");
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
|
|
||||||
if (this.appView != null) {
|
if (this.appView != null) {
|
||||||
@ -749,13 +751,6 @@ public class DroidGap extends Activity implements CordovaInterface {
|
|||||||
* End this activity by calling finish for activity
|
* End this activity by calling finish for activity
|
||||||
*/
|
*/
|
||||||
public void endActivity() {
|
public void endActivity() {
|
||||||
this.finish();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Finish for Activity has been called.
|
|
||||||
*/
|
|
||||||
public void finish() {
|
|
||||||
this.activityState = ACTIVITY_EXITING;
|
this.activityState = ACTIVITY_EXITING;
|
||||||
super.finish();
|
super.finish();
|
||||||
}
|
}
|
||||||
@ -902,21 +897,25 @@ public class DroidGap extends Activity implements CordovaInterface {
|
|||||||
final DroidGap me = this;
|
final DroidGap me = this;
|
||||||
me.runOnUiThread(new Runnable() {
|
me.runOnUiThread(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
AlertDialog.Builder dlg = new AlertDialog.Builder(me);
|
try {
|
||||||
dlg.setMessage(message);
|
AlertDialog.Builder dlg = new AlertDialog.Builder(me);
|
||||||
dlg.setTitle(title);
|
dlg.setMessage(message);
|
||||||
dlg.setCancelable(false);
|
dlg.setTitle(title);
|
||||||
dlg.setPositiveButton(button,
|
dlg.setCancelable(false);
|
||||||
new AlertDialog.OnClickListener() {
|
dlg.setPositiveButton(button,
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
new AlertDialog.OnClickListener() {
|
||||||
dialog.dismiss();
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
if (exit) {
|
dialog.dismiss();
|
||||||
me.endActivity();
|
if (exit) {
|
||||||
|
me.endActivity();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
});
|
dlg.create();
|
||||||
dlg.create();
|
dlg.show();
|
||||||
dlg.show();
|
} catch (Exception e) {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -1077,6 +1076,9 @@ public class DroidGap extends Activity implements CordovaInterface {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if ("exit".equals(id)) {
|
||||||
|
this.endActivity();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user