Reputation: 13
I'm developing an android app which has a lot of textviews and webviews with links. I need to open these links in a webview (not in an external web browser). How can I do this?
I've found a couple of similar threads:
The first one says I can use WebViewClient for WebViews. The second is about intent-filter and custom scheme. But the problem is that I'd like to find common solution which will work for webview and textviews (I also can't use custom scheme instead of 'http').
I've tried to do the following:
WebViewActivity has been created which will be used instead of web browser. In Android Manifest file I've set:
<activity android:name=".WebViewActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="http" />
</intent-filter>
</activity>
As a result, when a user tries to open a link, the app shows a dialog with suggestion to select needed application for watching the link (it suggests web browser and my WebViewActivity). How to open links in WebViewActivity without this dialog?
Thanks in advance.
Upvotes: 1
Views: 1994
Reputation: 4467
If the you click links in WebView, the new page will still be in the current webview by default.
For handle link clicks in TextView, you've already found this post handle textview link click in my android app , i think you can following Jonathan S. solution, by using clickable span.
If you register http schema for you activity, there will always has this dialog, unless no other apps register it.
Upvotes: 1