Question

I am displaying a webpage in my app using a webview, but i'd like to just launch the browser from my app. The problem is, I am using this method from the WebView class:

wv.loadDataWithBaseURL("http://somewebsite.com",responseQuery, "text/html", "utf-8", "");

followed by:

setContentView(wv);

how would I go about launching the browser from my app using my existing code? I cannot just use a standard intent because I need to attach all those other arguments since they are necessary (I was doing some POST requests before this lol).

Any links to relevant resources or example code would be highly appreciated! Thanks for your time.

Was it helpful?

Solution

AFAIK what you're trying to achieve is not possible. Any decent browser should disallow that for security reasons - it would mean that any app could trick the user into thinking that arbitrary HTML is loaded under a certain domain. This would allow an attacker to load malicious HTML under a trusted web site's domain (like the user's bank).

If you simply want to display some content you could consider loading the site as a data URL (data:text/html,) and set the base URL in the content's headers (so that CSS, etc.. resolve correctly). That would mean that the browser will display the entire data URL in the address bar though.

It seems like you're trying to render a response from some server in the WebView - would it be possible for you to construct the URL of the original query and send that to the Browser instead?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top