开发者

HTML5 Phonegap Android App - Open external URLs within app?

Currently in the process of building a HTML5/Jquery mobile shop Phonegap compiled Android App.

We need to process our orders by sending a URL to an external https webpage. Is it possible to open this page within our app rather that externally in the phones browser?

The external page contains a simple form - the user needs to enter a email and code into it and once submitted the page will return an encoded URL to the app.

I have seen this process several times in other apps, but have no idea开发者_如何学Go how to approach it. Can anyone help?

Thanks Paul


Sure it is, just use a WebView for this, implement your own WebViewClient to handle the clicks. This way you can handle links either internally or send them to the phone's browser. Have a look here: http://developer.android.com/reference/android/webkit/WebView.html

The Javadoc of the WebView has some samples on how to use it.


It is best to not load any new HTML pages in your app. If you need the equivalent of a new screen, add a hidden div to your page with display:none, hide the other divs, then make the new div visible with display:block. For transactions with your web server try to use only XHR. This is a little bit like loading a page in an iframe except that you have more control over it and you can even leverage the Phonegap API if needed.


What I personally use is a PhoneGap plugin called ChildBrowser which exists also for iOS. This plugin allows you to open an ADDITIONAL WebView as a modal dialog INSIDE your PhoneGap app! It's used for example in FaceBook login, I use it to show Files without leaving my app. Once the user is done and closes the dialog he's back in your app (he actually never left it), solving the issue for iOS users on "how to get back to the app"...

Hope this helps


You can include the external Website via an iFrame in your WebView.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜