How to access the phones browser

46 views
Skip to first unread message

Chris French

unread,
Jul 12, 2016, 6:57:34 AM7/12/16
to mgwt
Hi,

Does anyone know how I can call-out to the phone's browser with a URL that would then be loaded? I don't want to use a NamedFrame as I want it completely separate to my application. 

If I could do something like:

Browser.setUrl("http://google.com")

and this would then pop up - that would be great.

Many thanks as always :-)

Regards

Chris

 

venkata kiran surapaneni

unread,
Jul 13, 2016, 8:21:48 AM7/13/16
to mgwt
You will need to use gwt phonegap for accessing browser from the app. Sample code is below.

InAppBrowser inAppBrowser = phoneGap.getInAppBrowser();

 inAppBrowser = this.phoneGap.getInAppBrowser();

And you need to add InAppBrowser plugin to the cordova app.

Andrei Volgin

unread,
Jul 13, 2016, 12:35:35 PM7/13/16
to mgwt
I haven't done it in a long time, but this is the code that worked:

if (MGWT.getFormFactor().isPhone() && (MGWT.getOsDetection().isAndroid() || MGWT.getOsDetection().isIOs())) {

final InAppBrowserReference ref = phoneGap.getInAppBrowser().open(url, "", "");

ref.addExitHandler(new ExitHandler() {


@Override

public void onExit(ExitEvent event) {

Window.Location.reload();

ref.close();

}

});

}


Chris French

unread,
Jul 14, 2016, 4:51:21 AM7/14/16
to mgwt
Hi,

Many thanks for you reply so quickly.  

Unfortunately it does not work as I need it to on the iPhone/iPad.  It works fine on Android but on the iPhone it does not open a second browser it just replaces my application (I am running this in an xcode full-screen-browser wrapper).  The net result is that I can't return back to my application or even close the browser window as there is no location bar or toolbar.  I have tried adding these as shown below but without any luck.

PhoneGapBrowserImpl pg = new PhoneGapBrowserImpl();
pg.initializePhoneGap();
final InAppBrowserReference ref = pg.getInAppBrowser().open(url, "_system", "location=yes,presentationstyle=pagesheet,toolbarposition=bottom");
ref.addExitHandler(new ExitHandler() {
@Override
public void onExit(ExitEvent event) {

Window.Location.reload();
ref.close();
}
});

paul

unread,
Jul 15, 2016, 5:54:11 AM7/15/16
to mgwt
It has been a while since I looked at this but once you install the InAppBrowser plugin you can then simply use the standard Window.open methods with a few tweaks since the InAppBrowser plugin re-defines the Window.open and related methods

Android Chrome Browser and Safari IOS Browser - opens in new tab

Window.open(url,"_blank","")    

Phonegap (IOS and Android) - opens devices browser

    if (MGWT.getOsDetection().isAndroid())
    {
      Window.open(url, "_system", "location=no");
    }
    else
    {
      Window.open(url, "_blank", "location=no");
    }
Reply all
Reply to author
Forward
0 new messages