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();
}

本文标签: 下载页面跳转到没有安装判断是否网页