0
votes

How do I make apps which use WebView to render my website to open links in default browser ?

For example; I click on link to my website inside a mail which I read using Gmail, Gmail renders my website inside WebView and does the same for each link I click inside my website and do not suggest to open default browser

target="_blank" did not work

Am I depended on app's developer implementation or there is an html attribute magic ? they must override WebViewClient#shouldOverrideUrlLoading ?

1
The decision of how to handle links is up to the app (in this case, Gmail) and possibly the user (if the app allows configuration of this behavior). You do not get a vote. - CommonsWare
@CommonsWare I do not deserve a vote, why comment and not answer ? - whoopdedoo
My guess is that you are looking for some hack. Such a hack will not be reliable, as you have no way of knowing what the app is doing. For example, it might be rewriting the HTML to suit its needs, breaking your hack. But, it would not surprise me if there is some hack (HTML or JS) that works for some apps. - CommonsWare
precisely, its for CTF and I have the tools to monitor if it works - whoopdedoo

1 Answers

-1
votes

Very simple. Attached a WebViewClient to your WebView, and override the shouldOverrideUrlLoading function. In the fuction, check URL, if you want the WebView to handle it, return false, otherwise create an intent to launch browser, and return true.