diff --git a/framework/src/com/phonegap/DroidGap.java b/framework/src/com/phonegap/DroidGap.java index 1245d7c5..57421649 100755 --- a/framework/src/com/phonegap/DroidGap.java +++ b/framework/src/com/phonegap/DroidGap.java @@ -751,46 +751,49 @@ 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 params) { - try { - Intent intent = null; - if (usePhoneGap) { - intent = new Intent().setClass(this, com.phonegap.DroidGap.class); - intent.putExtra("url", url); + public void showWebPage(String url, boolean usePhoneGap, boolean clearPrev, HashMap params) throws android.content.ActivityNotFoundException { + Intent intent = null; + if (usePhoneGap) { + intent = new Intent().setClass(this, com.phonegap.DroidGap.class); + intent.putExtra("url", url); - // Add parameters - if (params != null) { - java.util.Set> s = params.entrySet(); - java.util.Iterator> it = s.iterator(); - while(it.hasNext()) { - Entry entry = it.next(); - String key = entry.getKey(); - Object value = entry.getValue(); - if (value == null) { - } - else if (value.getClass().equals(String.class)) { - intent.putExtra(key, (String)value); - } - else if (value.getClass().equals(Boolean.class)) { - intent.putExtra(key, (Boolean)value); - } - else if (value.getClass().equals(Integer.class)) { - intent.putExtra(key, (Integer)value); - } - } + // Add parameters + if (params != null) { + java.util.Set> s = params.entrySet(); + java.util.Iterator> it = s.iterator(); + while(it.hasNext()) { + Entry entry = it.next(); + String key = entry.getKey(); + Object value = entry.getValue(); + if (value == null) { + } + else if (value.getClass().equals(String.class)) { + intent.putExtra(key, (String)value); + } + else if (value.getClass().equals(Boolean.class)) { + intent.putExtra(key, (Boolean)value); + } + else if (value.getClass().equals(Integer.class)) { + intent.putExtra(key, (Integer)value); + } + } - } - } - else { - intent = new Intent(Intent.ACTION_VIEW); - intent.setData(Uri.parse(url)); - } - this.startActivity(intent); - } catch (android.content.ActivityNotFoundException e) { - System.out.println("DroidGap.showWebPage: Error loading url "+url+":"+ e.toString()); - } + } + } + else { + intent = new Intent(Intent.ACTION_VIEW); + intent.setData(Uri.parse(url)); + } + this.startActivity(intent); + + // 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) { - HashMap params = new HashMap(); - params.put("loadingDialog", ""); - params.put("hideLoadingDialogOnPageLoad", true); - this.ctx.showWebPage(url, true, params); + try { + HashMap params = new HashMap(); + params.put("loadingDialog", ""); + params.put("hideLoadingDialogOnPageLoad", true); + 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