Android一点 从js打开app
现在很多再浏览器点击可以打开app,如果有安装的话就打开,没有安装就跳到商店页面下载app,现在大多数做法都是使用的scheme的,这个js是无法判断有没安装app的,所以会导致无论怎么样都会打开一个下面,这个是不友好的,也和需求有出入。
从安卓6.0谷歌发布了App Links,这个和scheme有差别,谷歌是这么说的
所以谷歌推出了新的方式 App Links ,
我们可以再android studio上创建
创建完之后类似
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:scheme="https"
android:host="adv.xxx.com"
android:path="/xxx.jsp"/>
</intent-filter>
然后就可以弄个html测试就行
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
<button onclick="android()">点击</button>
<script type="text/javascript">
function android(){
console.log("----clcik----");
window.location.href = "https://xxx.com/xxx";
</script>
</body>
</html>