-1

I have a website and I have an simple app that have a simple webview.

When everybody has installed app they can click on links to my website. Those then should open in my app.

For example if my website is www.zoomit.ir and i click on https://www.zoomit.ir/2016/10/8/146994/todoist-tasklist-mobile-app/ in an social app like insta or telegram open my app and show that link

how to lunch app and get that link and show that in webview

  • There is a documentation at official page https://developer.android.com/training/app-links/index.html – Ufkoku Mar 01 '18 at 08:22

1 Answers1

0

In your AndroidManifest.xml file, try adding an intent filter in your <activity> which you want to open from the link

<activity
    android:name=".YourActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW"></action>

<category android:name="android.intent.category.DEFAULT"></category>
<category android:name="android.intent.category.BROWSABLE"></category>

<data
    android:host="www.zoomit.ir"
    android:scheme="http"></data>

</intent-filter>
</activity>

assuming www.zoomit.ir is the link which should open the app

Inorder to open this url in webview first get this url by using intent in your activity's onCreate

    String url;
    Intent intent = getIntent();
    String action = intent.getAction();
    Uri data = intent.getData();

 if (data!=null) {     
 webView.loadUrl(data.getScheme()+"://"+data.getHost()+data.getPath());
    }

Now you will have url="www.zoomit.ir/example-post". Use this url to load webview

Navneet Krishna
  • 5,009
  • 5
  • 25
  • 44