通过网页的JS代码启动移动APP

82 篇文章 0 订阅

http://blog.csdn.net/sky_monkey/article/details/22938125

少扯淡,直接上代码:

[php]  view plain copy 在CODE上查看代码片 派生到我的代码片
  1. <span style="font-size:18px;"><script>  
  2. function startAPP(){  
  3. window.location = "**://**.**/**";  
  4. }  
  5. function downloadAPP(){  
  6. window.location = "http://IP/**/**.apk";  
  7. }  
  8.   
  9. </script>  
  10. <style type="text/css">  
  11.         body{background:#D2D460;text-align:center;margin-top:10%}  
  12.         div{width:100%;margin:0 auto;background:#fff;text-align:left;}  
  13. </style>  
  14. </head>  
  15. <body>  
  16.   
  17. <?php   
  18. $var_name =  $_GET["isappinstalled"];   
  19. if ($var_name=="1"){  
  20.     echo '<img src=images/start.png alt=打开APP οnclick=startAPP() ></img>';  
  21. }else if ($var_name=="0"){  
  22.     echo '<img src=images/download.png alt=打开APP οnclick=downloadAPP() ></img>';  
  23. }else{  
  24.     echo '<img src=images/welcome.png alt=打开APP οnclick=startAPP() ></img>';  
  25. }  
  26. ?>  
  27.   
  28. </body></span>  


在app里面需要做以下设置(一般是在manifest.xml文件的activity的 intent filter里面)

[html]  view plain copy 在CODE上查看代码片 派生到我的代码片
  1. <span style="font-size:18px;"><intent-filter>  
  2.                <action android:name="android.intent.action.VIEW" />  
  3.                <category android:name="android.intent.category.DEFAULT" />  
  4.                <category android:name="android.intent.category.BROWSABLE" />  
  5.                <data   
  6.             android:scheme="**"   
  7.             android:host="**.**"   
  8.             android:pathPrefix="/**">  
  9.          </data>  
  10. </intent-filter></span>  


版权声明:本文为博主原创文章,未经博主允许不得转载。


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值