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

通过打开html启动app并传递参数

2017-08-22 20:16 399 查看
经常可以看到有些app可以通过网页打开,这是通过DeepLink来实现的

实现方式:在Activity中设置解析自定义协议

<activity android:name=".SplashActivity"

<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

<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="likui.me"
android:pathPrefix="/app"
android:scheme="app" />
</intent-filter>
</activity>


然后创建测试的html代码

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>test</title>
</head>
<body>
<br/>
<a href="app://gugu.prprlive.com/index.jsp">打开app</a><br/>
<br/>
<a href="app://gugu.prprlive.com/index.jsp?name=zhong">打开app(带参数)</a><br/>
<br/>
</body>
</html>


从上面的代码可以看到协议头是自定义的“app”,在测试过程中发现,href中的链接在浏览器输入框里面无法直接打开,只能在html代码中打开

持续更新中。。。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  android app deeplink
相关文章推荐