Hi Joshiah!
Is it possible to have some links be launched by their native apps?
Longer story:
I was looking for this, as I have something similar on my iPhone app.
However, when I link to a (external) video file on the iphone, it's
still handled by the video player on the OS. On Android this is not
the case: Without the patch above, it launches the browser, which
launches the video player (but if you go back you end up in the
browser, not the original app). If I apply this code above, no links
ever open outside the app (good!), but also the video files won't play
(bad), most likely because the browser itself can't handle these.
Any idea how to fix this? Is it possible to detect the file type, or
url, and have that handled by external programs, while keeping other
links in the app?
(my video links have a redirect, added by our loadbalancers.).
Thanks a lot!
PanMan.
On May 6, 6:25 am, Ray <
rnva...@googlemail.com> wrote:
> Hi Josiah,
>
> this is something I haven't got around to contributing back yet:
>
> To keep future url clicks in the same window and not use the phones
> default browser, you need to use webviewclient
>
> In the main class file before the bindBrowser(appView); add the
> following:
> Note that the error page is optional but I think it's very worthwhile
> including, you will need to add the errorpage.txt file to your project
> assets directory.
>
> /* WebViewClient prevents remote urls from opening a new
> browser window */
> appView.setWebViewClient(new WebViewClient() {
> @Override
> public void onReceivedError(WebViewview, int errorCode,
> String description, String failingUrl)
> {
> appView.stopLoading();
> appView.loadUrl("file:///android_asset/errorpage.txt");
> }
> });
>
> /* Bind the appView object to the gap class methods */
> bindBrowser(appView);
>
> Cheers
> Ray
>
> On May 6, 5:09 am, Josiah <
josiahlcarl...@gmail.com> wrote:
>
> > I figure since this seems to influence everyone who uses PhoneGap
> >Androidthis way, it may be of benefit to more than just me. Where
> >Androidgives away the URL of the webapp, it seems to undermine the
> > > I've setup myAndroidapp just like the Wiki setup directions using