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

网页上启动特定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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐