Improve closing an HTML page and returning to previous page.

This commit is contained in:
Bryce Curtis
2011-09-29 11:02:54 -05:00
parent a4d66c63a4
commit ebb9f09168
3 changed files with 33 additions and 10 deletions
+9 -9
View File
@@ -716,13 +716,6 @@ public class DroidGap extends PhonegapActivity {
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
this.appView.loadUrl("javascript:try{PhoneGap.onPause.fire();}catch(e){};");
@@ -816,7 +809,7 @@ public class DroidGap extends PhonegapActivity {
// Finish current activity
if (clearPrev) {
this.finish();
this.endActivity();
}
}
@@ -1300,6 +1293,13 @@ public class DroidGap extends PhonegapActivity {
}
}
/**
* End this activity by simulating backbutton keypress
*/
public void endActivity() {
super.onKeyDown(KeyEvent.KEYCODE_BACK, new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_BACK));
}
/**
* Called when a key is pressed.
*
@@ -1408,7 +1408,7 @@ public class DroidGap extends PhonegapActivity {
// If terminating app, then shut down this activity too
if (resultCode == Activity.RESULT_OK) {
this.setResult(Activity.RESULT_OK);
this.onDestroy();
this.endActivity();
}
return;
}