15

Launch app when click on url if app installed on device. if app not installed on device, open playstore.

<activity android:name=".ui.NewsCardActivity">
    <intent-filter>
        <data android:scheme="app" />
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
    </intent-filter>
</activity>
masud_moni
  • 1,121
  • 16
  • 33
Divyesh Rudani
  • 231
  • 1
  • 2
  • 13
  • 2
    Possible duplicate of [How to implement my very own URI scheme on Android](http://stackoverflow.com/questions/2448213/how-to-implement-my-very-own-uri-scheme-on-android) – Ostin Jan 23 '17 at 14:48

1 Answers1

24

You have to deep link your app, add following lines in activity (Manifiest.xml) which you want to launch

<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:host="screen" android:scheme="appname"/>
</intent-filter>

in browser when ever you click appname://screen your app activity will be launched,

replace appname and screen as per your requirement

Note if you type this url in browser it will search in google ,for this to work you have to write link in html page

<a href="appname://screen">Some text</a>

If not working the add android:exported="true" in activity

<activity
    android:name=".activity.MainActivity"
    android:exported="true">
masud_moni
  • 1,121
  • 16
  • 33
Manohar
  • 22,116
  • 9
  • 108
  • 144
  • the appname:// is the app itselp . is the screen the page /directory? – Kofi Sammie Jan 19 '18 at 16:58
  • for example you want to launch profile activity in your app when user clicks a link , then your screen name should be something like "profile" so its easily understandable . – Manohar Jan 20 '18 at 04:53