How to launch app on click of url in android

Deadly 提交于 2019-11-26 16:46:42

问题


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

        <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>

回答1:


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



来源:https://stackoverflow.com/questions/41807300/how-to-launch-app-on-click-of-url-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!