Tarik
Tarik

Reputation: 81721

Intent Filter for Viewing Web Pages

On this page of Android Development, -at step 6- they say :

Instead of adding an intent filter to view web pages, you can override the WebViewClient class and enable this Activity to handle its own URL requests.

But I would like to learn how to do it with intent-filters as well.

I have a WebView widget and a Button widget on my default Activity and when user clicks on the Button, the WebView loads a page - pretty simple. But as it is mentioned in Step-6, I need to enable my Activity to do so.

Can somebody show me intent-filter which does the same things here as WebViewClient - overriding shouldOverrideUrlLoading(WebView view, String url) method.

Thanks in advance.

Upvotes: 0

Views: 1679

Answers (1)

CommonsWare
CommonsWare

Reputation: 1006799

But I would like to learn how to do it with intent-filters as well.

This is effectively the same thing as a previous question, asked minutes before yours, though they might not seem so on the surface.

You can advertise, via a properly-constructed <data> element in your <intent-filter>, that you can VIEW documents that are text/html. However, the user will be prompted for every link to a Web page they click on anywhere on their phone (plus redirects).

Upvotes: 2

Related Questions