admin管理员组文章数量:1530046
下面是测试网页的内容:
<html>
<head><script type="text/javascript">
//判断手机上是否安装了app,如果安装直接打开,如果没安装,跳转到下载页面
function openApp(url) {
var timeout, t = 1000, hasApp = true;
var openScript = setTimeout(function () {
if (!hasApp) {
var durl = "http:www.baidu";
window.location.href=durl;
}
document.body.removeChild(ifr);
}, 2000)
var t1 = Date.now();
var ifr = document.createElement("iframe");
ifr.setAttribute('src', url);
ifr.setAttribute('style', 'display:none');
document.body.appendChild(ifr);
timeout = setTimeout(function () {
var t2 = Date.now();
if (!t1 || t2 - t1 < t + 100) {
hasApp = false;
}
}, t);
}
</script>
</head>
<body >
<input type="hidden" id="downloadUrl" name="downloadUrl" value="http:www.baidu"/>
<div>
<a href="javascript:void(0);" οnclick='openApp("zdykapphaoyuntao://");' >Client</a>
</div>
<br/>
</body>
</html>
客户端以android举例:需要在AndroidManifest.xml文件启动activity下面加入 <data android:scheme="zdykapphaoyuntao" />
这样配置好后就在可以启动的activity里面拿到各种需要的数据:如下
Intent intent = getIntent();
Uri data = intent.getData();
if (null != data) {
String host = data.getHost();
String path = data.getPath();
String query = data.getQuery();
if (host.equals("productdetail")) {// 商品详情
intent = new Intent(ActWelcomeNow.this, ActGoodsDetail.class);
intent.putExtra(Contant.NAME, query);
ActWelcomeNow.this.startActivity(intent);
ActWelcomeNow.this.finish();
} else if (host.equals("shopindex")) {// 店铺首页
intent = new Intent(ActWelcomeNow.this, ActShopIndex.class);
intent.putExtra(Contant.NAME, query);
ActWelcomeNow.this.startActivity(intent);
ActWelcomeNow.this.finish();
}
版权声明:本文标题:网页判断判断是否安装APP并启动,没有安装就跳转到下载页面 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://m.elefans.com/dianzi/1726630485a1079136.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论