forked from github/cordova-android
When app.exitApp() is called on multi-page app, pass to previous pages in stack and close them too.
This commit is contained in:
parent
025577c41d
commit
0f988717d0
@ -10,6 +10,7 @@ package com.phonegap;
|
|||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
import android.app.Activity;
|
||||||
import com.phonegap.api.Plugin;
|
import com.phonegap.api.Plugin;
|
||||||
import com.phonegap.api.PluginResult;
|
import com.phonegap.api.PluginResult;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -172,7 +173,8 @@ public class App extends Plugin {
|
|||||||
* Exit the Android application.
|
* Exit the Android application.
|
||||||
*/
|
*/
|
||||||
public void exitApp() {
|
public void exitApp() {
|
||||||
((DroidGap)this.ctx).finish();
|
((DroidGap)this.ctx).setResult(Activity.RESULT_OK);
|
||||||
|
((DroidGap)this.ctx).onDestroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -155,6 +155,7 @@ public class DroidGap extends PhonegapActivity {
|
|||||||
// Plugin to call when activity result is received
|
// Plugin to call when activity result is received
|
||||||
protected IPlugin activityResultCallback = null;
|
protected IPlugin activityResultCallback = null;
|
||||||
protected boolean activityResultKeepRunning;
|
protected boolean activityResultKeepRunning;
|
||||||
|
private static int PG_REQUEST_CODE = 99;
|
||||||
|
|
||||||
// Flag indicates that a loadUrl timeout occurred
|
// Flag indicates that a loadUrl timeout occurred
|
||||||
private int loadUrlTimeout = 0;
|
private int loadUrlTimeout = 0;
|
||||||
@ -714,7 +715,14 @@ public class DroidGap extends PhonegapActivity {
|
|||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
|
|
||||||
if (this.appView != null) {
|
if (this.appView != null) {
|
||||||
|
|
||||||
|
// Make invisible
|
||||||
|
DroidGap.this.runOnUiThread(new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
DroidGap.this.setVisible(false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Make sure pause event is sent if onPause hasn't been called before onDestroy
|
// Make sure pause event is sent if onPause hasn't been called before onDestroy
|
||||||
this.appView.loadUrl("javascript:try{PhoneGap.onPause.fire();}catch(e){};");
|
this.appView.loadUrl("javascript:try{PhoneGap.onPause.fire();}catch(e){};");
|
||||||
|
|
||||||
@ -727,6 +735,9 @@ public class DroidGap extends PhonegapActivity {
|
|||||||
// Forward to plugins
|
// Forward to plugins
|
||||||
this.pluginManager.onDestroy();
|
this.pluginManager.onDestroy();
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
this.finish();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -788,19 +799,20 @@ public class DroidGap extends PhonegapActivity {
|
|||||||
intent.putExtra(key, (Integer)value);
|
intent.putExtra(key, (Integer)value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
super.startActivityForResult(intent, PG_REQUEST_CODE);
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
intent = new Intent(Intent.ACTION_VIEW);
|
intent = new Intent(Intent.ACTION_VIEW);
|
||||||
intent.setData(Uri.parse(url));
|
intent.setData(Uri.parse(url));
|
||||||
|
this.startActivity(intent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
intent = new Intent(Intent.ACTION_VIEW);
|
intent = new Intent(Intent.ACTION_VIEW);
|
||||||
intent.setData(Uri.parse(url));
|
intent.setData(Uri.parse(url));
|
||||||
|
this.startActivity(intent);
|
||||||
}
|
}
|
||||||
this.startActivity(intent);
|
|
||||||
|
|
||||||
// Finish current activity
|
// Finish current activity
|
||||||
if (clearPrev) {
|
if (clearPrev) {
|
||||||
@ -1233,12 +1245,13 @@ public class DroidGap extends PhonegapActivity {
|
|||||||
this.ctx.clearHistory = false;
|
this.ctx.clearHistory = false;
|
||||||
this.ctx.appView.clearHistory();
|
this.ctx.appView.clearHistory();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Shutdown if blank loaded
|
// Shutdown if blank loaded
|
||||||
if (url.equals("about:blank")) {
|
if (url.equals("about:blank")) {
|
||||||
if (this.ctx.callbackServer != null) {
|
if (this.ctx.callbackServer != null) {
|
||||||
this.ctx.callbackServer.destroy();
|
this.ctx.callbackServer.destroy();
|
||||||
}
|
}
|
||||||
|
this.ctx.finish();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1389,6 +1402,17 @@ public class DroidGap extends PhonegapActivity {
|
|||||||
*/
|
*/
|
||||||
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
|
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
|
||||||
super.onActivityResult(requestCode, resultCode, intent);
|
super.onActivityResult(requestCode, resultCode, intent);
|
||||||
|
|
||||||
|
// If a subsequent DroidGap activity is returning
|
||||||
|
if (requestCode == PG_REQUEST_CODE) {
|
||||||
|
// If terminating app, then shut down this activity too
|
||||||
|
if (resultCode == Activity.RESULT_OK) {
|
||||||
|
this.setResult(Activity.RESULT_OK);
|
||||||
|
this.onDestroy();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
IPlugin callback = this.activityResultCallback;
|
IPlugin callback = this.activityResultCallback;
|
||||||
if (callback != null) {
|
if (callback != null) {
|
||||||
callback.onActivityResult(requestCode, resultCode, intent);
|
callback.onActivityResult(requestCode, resultCode, intent);
|
||||||
|
Loading…
Reference in New Issue
Block a user