首页 > 移动平台 > 详细

安卓手机浏览器判断是否安装了android客户端程序

时间:2015-08-20 17:05:36      阅读:245      评论:0      收藏:0      [点我收藏+]

    android项目里面androidManifest.xml文件对activity的配置如下:

<activity android:name=".MainActivity" android:screenOrientation="portrait">    
  <intent-filter>        
   <data android:scheme="http" android:host="192.168.1.9" android:port="8088" android:path="/test/download.html"/>        
   <action android:name="android.intent.action.VIEW" />        
   <category android:name="android.intent.category.DEFAULT" />        
   <category android:name="android.intent.category.BROWSABLE" />   
  </intent-filter>  
 </activity>

在androidManifest.xml中配置的filter中data的属性定义的scheme,host,port,path,与HTML中要全部一致。

HTML页面代码如下:

<a id="applink" href="http://192.168.1.9:8088/test/download.html">立即查看</a>

所以这时就有两个程序能处理这个跳转链接:一个是系统的browser,一个是配置了intent-filter的activity。

如果说本机没有安装这个应用程序,那么这个download.html里面可以forward到android的应用商店并根据参数进入搜索页面并显示结果安装软件。(包含以下代码)

<script type="text/javascript">window.location="market://search?q=com.xxx.xxx";</script>

安卓手机浏览器判断是否安装了android客户端程序

原文:http://my.oschina.net/wangsigang/blog/495082

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!