mirror of
https://github.com/apache/cordova-android.git
synced 2025-04-24 18:30:12 +08:00
Bug 110 - When you close an app on Android you see a JS error in logcat.
This commit is contained in:
parent
04de2052fd
commit
935295c9b8
@ -18,6 +18,8 @@
|
|||||||
* onPhoneGapInfoReady Internal event fired when device properties are available
|
* onPhoneGapInfoReady Internal event fired when device properties are available
|
||||||
* onDeviceReady User event fired to indicate that PhoneGap is ready
|
* onDeviceReady User event fired to indicate that PhoneGap is ready
|
||||||
* onResume User event fired to indicate a start/resume lifecycle event
|
* onResume User event fired to indicate a start/resume lifecycle event
|
||||||
|
* onPause User event fired to indicate a pause lifecycle event
|
||||||
|
* onDestroy Internal event fired when app is being destroyed (User should use window.onunload event, not this one).
|
||||||
*
|
*
|
||||||
* The only PhoneGap events that user code should register for are:
|
* The only PhoneGap events that user code should register for are:
|
||||||
* onDeviceReady
|
* onDeviceReady
|
||||||
@ -26,6 +28,7 @@
|
|||||||
* Listeners can be registered as:
|
* Listeners can be registered as:
|
||||||
* document.addEventListener("deviceready", myDeviceReadyListener, false);
|
* document.addEventListener("deviceready", myDeviceReadyListener, false);
|
||||||
* document.addEventListener("resume", myResumeListener, false);
|
* document.addEventListener("resume", myResumeListener, false);
|
||||||
|
* document.addEventListener("pause", myPauseListener, false);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (typeof(DeviceInfo) !== 'object') {
|
if (typeof(DeviceInfo) !== 'object') {
|
||||||
@ -241,6 +244,17 @@ PhoneGap.onResume = new PhoneGap.Channel('onResume');
|
|||||||
*/
|
*/
|
||||||
PhoneGap.onPause = new PhoneGap.Channel('onPause');
|
PhoneGap.onPause = new PhoneGap.Channel('onPause');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* onDestroy channel is fired when the PhoneGap native code
|
||||||
|
* is destroyed. It is used internally.
|
||||||
|
* Window.onunload should be used by the user.
|
||||||
|
*/
|
||||||
|
PhoneGap.onDestroy = new PhoneGap.Channel('onDestroy');
|
||||||
|
PhoneGap.onDestroy.subscribeOnce(function() {
|
||||||
|
PhoneGap.shuttingDown = true;
|
||||||
|
});
|
||||||
|
PhoneGap.shuttingDown = false;
|
||||||
|
|
||||||
// _nativeReady is global variable that the native side can set
|
// _nativeReady is global variable that the native side can set
|
||||||
// to signify that the native code is ready. It is a global since
|
// to signify that the native code is ready. It is a global since
|
||||||
// it may be called before any PhoneGap JS is ready.
|
// it may be called before any PhoneGap JS is ready.
|
||||||
@ -696,6 +710,11 @@ PhoneGap.JSCallbackToken = null;
|
|||||||
*/
|
*/
|
||||||
PhoneGap.JSCallback = function() {
|
PhoneGap.JSCallback = function() {
|
||||||
|
|
||||||
|
// Exit if shutting down app
|
||||||
|
if (PhoneGap.shuttingDown) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// If polling flag was changed, start using polling from now on
|
// If polling flag was changed, start using polling from now on
|
||||||
if (PhoneGap.UsePolling) {
|
if (PhoneGap.UsePolling) {
|
||||||
PhoneGap.JSCallbackPolling();
|
PhoneGap.JSCallbackPolling();
|
||||||
@ -708,6 +727,11 @@ PhoneGap.JSCallback = function() {
|
|||||||
xmlhttp.onreadystatechange=function(){
|
xmlhttp.onreadystatechange=function(){
|
||||||
if(xmlhttp.readyState === 4){
|
if(xmlhttp.readyState === 4){
|
||||||
|
|
||||||
|
// Exit if shutting down app
|
||||||
|
if (PhoneGap.shuttingDown) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// If callback has JavaScript statement to execute
|
// If callback has JavaScript statement to execute
|
||||||
if (xmlhttp.status === 200) {
|
if (xmlhttp.status === 200) {
|
||||||
|
|
||||||
@ -786,6 +810,11 @@ PhoneGap.UsePolling = false; // T=use polling, F=use XHR
|
|||||||
*/
|
*/
|
||||||
PhoneGap.JSCallbackPolling = function() {
|
PhoneGap.JSCallbackPolling = function() {
|
||||||
|
|
||||||
|
// Exit if shutting down app
|
||||||
|
if (PhoneGap.shuttingDown) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// If polling flag was changed, stop using polling from now on
|
// If polling flag was changed, stop using polling from now on
|
||||||
if (!PhoneGap.UsePolling) {
|
if (!PhoneGap.UsePolling) {
|
||||||
PhoneGap.JSCallback();
|
PhoneGap.JSCallback();
|
||||||
|
@ -650,6 +650,9 @@ public class DroidGap extends PhonegapActivity {
|
|||||||
// 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){};");
|
||||||
|
|
||||||
|
// Send destroy event to JavaScript
|
||||||
|
this.appView.loadUrl("javascript:try{PhoneGap.onDestroy.fire();}catch(e){};");
|
||||||
|
|
||||||
// Load blank page so that JavaScript onunload is called
|
// Load blank page so that JavaScript onunload is called
|
||||||
this.appView.loadUrl("about:blank");
|
this.appView.loadUrl("about:blank");
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user