您的位置:首页 > 移动开发 > Android开发

短信或h5页面唤起android app

2015-09-12 19:50 393 查看

android短信或h5页面唤起app

需求

点击短信或h5内链接跳转:若androud手机安装了目标app则跳到该app某页面;若没安装则跳到app的html下载页

思路

通过scheme机制实现页面唤起。

实现

android app内页面scheme配置

<activity
            android:name="com.example.test4link2app_target.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <data
                    android:host="my.host.com"
                    android:path="/get/info"
                    android:scheme="myscheme" />

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

                <action android:name="android.intent.action.VIEW" />

                <category android:name="android.intent.category.BROWSABLE" />
            </intent-filter>
        </activity>


h5页面配置

<a href="myscheme://my.host.com/get/info?id=10000" >点击打开目标app</a>


Demo工程

https://github.com/cheyiliu/test4XXX/tree/master/test4link2app_target

https://github.com/cheyiliu/test4XXX/tree/master/test4link2app_lancher

其他

这里自定义的scheme可以考虑采用http,但这样会导致在点击链接后系统弹出一个选择框,若本地安装了app则app会出现在列表,若没安装则默认器浏览器

android6已经支持这种无缝跳转了
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: