0

I want to open my app and load the URL when specific links are clicked.

This is my Manifest for handling external links.

<intent-filter android:autoVerify="true">
    <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" android:host="www.android.com" />
    <data android:scheme="https" android:host="www.android.com" />
</intent-filter>

And for handling incoming links this is the code

    intentData = getIntent().getData();
    if(intentData !=null){
        loadUrl = intentData.toString();
    }else {
        loadUrl = "https://www.android.com";
    }
    webView.loadUrl(loadUrl);

Now when I clicked https://www.android.com from external app like whatsapp its loaded in webview but the webview is attached to whatsapp. Check screenshots below.

Normal Webview enter image description here


And if anyone can give me any hints or guide me on how to open my app when I open the URL(https://www.android.com) from Google Chrome(in my phone) will be a great help

Sp4Rx
  • 1,498
  • 3
  • 20
  • 37

3 Answers3

1

For second part of your question:

And if anyone can give me any hints or guide me on how to open my app when I open the URL(https://www.android.com) from Google Chrome(in my phone) will be a great help

take a look at this answer:

"Essentially, the Chrome team feels that if a user actually types something into the address bar, no redirect should ever happen. As you've discovered, this is counter to behavior in all other browsers."

Community
  • 1
  • 1
Andrii Omelchenko
  • 13,183
  • 12
  • 43
  • 79
0

You can find detail implementation here, https://developer.android.com/guide/webapps/webview.html

You have to override methods, and handle clicks.

Sachchidanand
  • 1,291
  • 2
  • 18
  • 35
0

Use this line in Manifest file of your Activity which is Handling that intent to avoid such problem.

android:launchMode="singleTask"
pacholik
  • 8,607
  • 9
  • 43
  • 55
Vishal Dalve
  • 324
  • 3
  • 16