网页上启动特定android应用,如果安装就打开,如果未安装就跳到下载页面
2014-10-30 14:17
501 查看
android应用要配置的部分
这个加到你要启动的activity里面,manifest
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="com.example.urltest"
android:scheme="lianlian" />
</intent-filter>
scheme 和host部分可以自己定义,不过一定要跟intent-filter 里面的对应
html部分
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript">
function launchAndroidApp()
{
window.location.href='lianlian://com.example.urltest';
setTimeout(function(){ window.location.href="http://www.junbao.net/login.do" }, 3000);
}
</script>
</head>
<body>
<input type="button" onclick="launchAndroidApp()" value="launch app or download">
</body>
</html>
ps:测试效果的时候,html文件在手机上一定要使用浏览器打开,如果使用htmlviewer,问题来了,安眠药哪家强?
demo code:
https://github.com/MasterChenGitHub/LaunchAppFromWebPage
这个加到你要启动的activity里面,manifest
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="com.example.urltest"
android:scheme="lianlian" />
</intent-filter>
scheme 和host部分可以自己定义,不过一定要跟intent-filter 里面的对应
html部分
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript">
function launchAndroidApp()
{
window.location.href='lianlian://com.example.urltest';
setTimeout(function(){ window.location.href="http://www.junbao.net/login.do" }, 3000);
}
</script>
</head>
<body>
<input type="button" onclick="launchAndroidApp()" value="launch app or download">
</body>
</html>
ps:测试效果的时候,html文件在手机上一定要使用浏览器打开,如果使用htmlviewer,问题来了,安眠药哪家强?
demo code:
https://github.com/MasterChenGitHub/LaunchAppFromWebPage
相关文章推荐
- HTML5打开本地app应用的方法,如果你的手机上安装App,就会自动打app,否则在页面上会提示你进行下载app
- android:如果手机安装了app则打开一个activity,如果没有安装则去到android market如何在HTML页面实现
- Android Intent应用,打开网页,安装程序,打电话,打开地图等功能
- AndroidIntent应用,打开网页,安装程序,打电话,打开地图等功能
- Android Intent应用,打开网页,安装程序,打电话,打开地图等功能
- Android Intent应用,打开网页,安装程序,打电话,打开地图等功能
- 给你的移动网站加点料:推荐下载App,如果本地安装则直接打开本地App(Android/IOS)
- 判断某一款应用(通过包名)是否安装,如果安装直接打开,否则弹出下载对话框(V1.0)
- Android 打开其他应用,如果未安装进行提示代码
- Android应用检查更新下载安装打开
- 网页判断判断是否安装APP并启动,没有安装就跳转到下载页面
- Android Intent应用,打开网页,安装程序,打电话,打开地图等功能
- Android Intent应用,打开网页,安装程序,打电话,打开地图等功能
- Android ,下载安装apk 启动一个应用
- android 解决两个应用互相跳转,如果应用已经启动还是会重新打开应用的问题
- 给你的移动网站加点料:推荐下载App,如果本地安装则直接打开本地App(Android/IOS)
- 解决 在线视频,当打开页面时,如果安装了迅雷,会提示下载的问题。
- AndroidIntent应用,打开网页,安装程序,打电话,打开地图等功能 .
- Android Intent应用,打开网页,安装程序,打电话,打开地图等功能
- 给你的移动网站加点料:推荐下载App,如果本地安装则直接打开本地App(Android/IOS)