经常可以看到有些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代码中打开
持续更新中。。。