How to launch app on click of url in android
Asked Answered
I

1

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>
Idette answered 23/1, 2017 at 13:15 Comment(1)
Possible duplicate of How to implement my very own URI scheme on AndroidNondisjunction
R
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">
Ruebenrueda answered 23/1, 2017 at 13:27 Comment(3)
the appname:// is the app itselp . is the screen the page /directory?Liminal
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 .Ruebenrueda
thanks for answer but its not working i tried to enter appname://screen its searching on google app is not launchingCassandracassandre

© 2022 - 2024 — McMap. All rights reserved.