mirror of
https://github.com/apache/cordova-android.git
synced 2025-03-16 00:11:03 +08:00
Use endActivity() for consistency. Improve error handling.
This commit is contained in:
parent
ea87dfe08a
commit
1f8d6b4866
@ -761,7 +761,7 @@ public class DroidGap extends PhonegapActivity {
|
|||||||
this.pluginManager.onDestroy();
|
this.pluginManager.onDestroy();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.finish();
|
this.endActivity();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1248,22 +1248,23 @@ public class DroidGap extends PhonegapActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Make app visible after 2 sec in case there was a JS error and PhoneGap JS never initialized correctly
|
// Make app visible after 2 sec in case there was a JS error and PhoneGap JS never initialized correctly
|
||||||
Thread t = new Thread(new Runnable() {
|
if (appView.getVisibility() == View.INVISIBLE) {
|
||||||
public void run() {
|
Thread t = new Thread(new Runnable() {
|
||||||
try {
|
public void run() {
|
||||||
Thread.sleep(2000);
|
try {
|
||||||
ctx.runOnUiThread(new Runnable() {
|
Thread.sleep(2000);
|
||||||
public void run() {
|
ctx.runOnUiThread(new Runnable() {
|
||||||
appView.setVisibility(View.VISIBLE);
|
public void run() {
|
||||||
ctx.spinnerStop();
|
appView.setVisibility(View.VISIBLE);
|
||||||
}
|
ctx.spinnerStop();
|
||||||
});
|
}
|
||||||
} catch (InterruptedException e) {
|
});
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
});
|
t.start();
|
||||||
t.start();
|
}
|
||||||
|
|
||||||
|
|
||||||
// Clear history, so that previous screen isn't there when Back button is pressed
|
// Clear history, so that previous screen isn't there when Back button is pressed
|
||||||
if (this.ctx.clearHistory) {
|
if (this.ctx.clearHistory) {
|
||||||
@ -1276,7 +1277,7 @@ public class DroidGap extends PhonegapActivity {
|
|||||||
if (this.ctx.callbackServer != null) {
|
if (this.ctx.callbackServer != null) {
|
||||||
this.ctx.callbackServer.destroy();
|
this.ctx.callbackServer.destroy();
|
||||||
}
|
}
|
||||||
this.ctx.finish();
|
this.ctx.endActivity();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1469,19 +1470,19 @@ public class DroidGap extends PhonegapActivity {
|
|||||||
|
|
||||||
// If errorUrl specified, then load it
|
// If errorUrl specified, then load it
|
||||||
final String errorUrl = me.getStringProperty("errorUrl", null);
|
final String errorUrl = me.getStringProperty("errorUrl", null);
|
||||||
if ((errorUrl != null) && errorUrl.startsWith("file://") && (!failingUrl.equals(errorUrl))) {
|
if ((errorUrl != null) && (errorUrl.startsWith("file://") || errorUrl.indexOf(me.baseUrl) == 0 || isUrlWhiteListed(errorUrl)) && (!failingUrl.equals(errorUrl))) {
|
||||||
|
|
||||||
// Load URL on UI thread
|
// Load URL on UI thread
|
||||||
me.runOnUiThread(new Runnable() {
|
me.runOnUiThread(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
me.appView.loadUrl(errorUrl);
|
me.showWebPage(errorUrl, true, true, null);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// If not, then display error dialog
|
// If not, then display error dialog
|
||||||
else {
|
else {
|
||||||
me.appView.loadUrl("about:blank");
|
me.appView.setVisibility(View.GONE);
|
||||||
me.displayError("Application Error", description + " ("+failingUrl+")", "OK", true);
|
me.displayError("Application Error", description + " ("+failingUrl+")", "OK", true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1507,7 +1508,7 @@ public class DroidGap extends PhonegapActivity {
|
|||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
if (exit) {
|
if (exit) {
|
||||||
me.finish();
|
me.endActivity();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user