mirror of
https://github.com/apache/cordova-android.git
synced 2025-03-16 16:31:12 +08:00
Add more control over how url is loaded.
This commit is contained in:
parent
1e3422ae70
commit
9643314553
@ -751,10 +751,11 @@ public class DroidGap extends PhonegapActivity {
|
||||
*
|
||||
* @param url The url to load.
|
||||
* @param usePhoneGap Load url in PhoneGap webview.
|
||||
* @return "" if ok, or error message.
|
||||
* @param clearPrev Clear the activity stack, so new app becomes top of stack
|
||||
* @param params DroidGap parameters for new app
|
||||
* @throws android.content.ActivityNotFoundException
|
||||
*/
|
||||
public void showWebPage(String url, boolean usePhoneGap, HashMap<String, Object> params) {
|
||||
try {
|
||||
public void showWebPage(String url, boolean usePhoneGap, boolean clearPrev, HashMap<String, Object> params) throws android.content.ActivityNotFoundException {
|
||||
Intent intent = null;
|
||||
if (usePhoneGap) {
|
||||
intent = new Intent().setClass(this, com.phonegap.DroidGap.class);
|
||||
@ -788,8 +789,10 @@ public class DroidGap extends PhonegapActivity {
|
||||
intent.setData(Uri.parse(url));
|
||||
}
|
||||
this.startActivity(intent);
|
||||
} catch (android.content.ActivityNotFoundException e) {
|
||||
System.out.println("DroidGap.showWebPage: Error loading url "+url+":"+ e.toString());
|
||||
|
||||
// Finish current activity
|
||||
if (clearPrev) {
|
||||
this.finish();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1127,10 +1130,14 @@ public class DroidGap extends PhonegapActivity {
|
||||
// NOTE: This replaces our app with new URL. When BACK is pressed,
|
||||
// our app is reloaded and restarted. All state is lost.
|
||||
if (this.ctx.loadInWebView || url.startsWith("file://") || url.indexOf(this.ctx.baseUrl) == 0) {
|
||||
try {
|
||||
HashMap<String, Object> params = new HashMap<String, Object>();
|
||||
params.put("loadingDialog", "");
|
||||
params.put("hideLoadingDialogOnPageLoad", true);
|
||||
this.ctx.showWebPage(url, true, params);
|
||||
this.ctx.showWebPage(url, true, true, params);
|
||||
} catch (android.content.ActivityNotFoundException e) {
|
||||
System.out.println("Error loading url into DroidGap - "+url+":"+ e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
// If not our application, let default viewer handle
|
||||
|
Loading…
x
Reference in New Issue
Block a user