How do I only get links from my domain to open my application?

Asked

Viewed 122 times

1

If I click on a link related to my site, I would like in the list of applications that can open that link (Google Chrome, UC Browser and etc), also appear my application, which is a very simple browser that works using a Webview, but only when it is a link to my website.

This is the code of my app:

mWebView = (WebView) findViewById(R.id.webview);
mWebView.loadUrl("http://google.com");
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.getSettings().setSupportZoom(false);
mWebView.setWebViewClient(new LinkWebViewClient());

Someone has clues as to how to do this?

1 answer

1


You have to change the intent-filter, which is found in Manisfest.xml, from Activity that will respond to Intent, for something like this:

<intent-filter>

    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />
    <data android:scheme="http" />
    <data android:host="oSeuDominio.???" />
    <data android:host="www.oSeuDominio.???" />
    <data android:pathPattern="/.*" />

</intent-filter>  

Substitute oSeuDominio.??? according to their domain.

  • Right, more like: if the link has this format: Meudominio.com/pagina2.html opens is the index of the site. How does this to open the requested link instead of the index?

  • That’s all the link you want to open?

  • No. It’s just that my site has several pages... or so: any link that contains my domain.

  • Edit the question and enter the code you are using. My answer should work for any link in your domain, so you are using it <data android:pathPattern="/.*" />

  • I believe you must manipulate something in java to receive the link. I’m going to a search

  • With the intent-filter answer your application already appears in the list under the conditions you intended?

  • yes appears, just does not open the link I clicked. Opens is the index of the site.

  • Then your question has been answered. It is best to open another question for this new problem. Put in it the code you are using to get the link.

  • Thank you! Thank you!

  • See my new question: http://answall.com/questions/143280/webview-n%C3%A3o-opens-the-link-requested

Show 5 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.