【Android】webview点击跳转APP

本文介绍如何在AndroidManifest文件中配置特定路径的intent-filter,并通过HTML页面实现应用内跳转。详细展示了data标签的使用方法,包括设置scheme、host、port和path属性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在AndroidMainfest文件中的activity中添加:
<intent-filter>
                 <!--路径匹配  协议://主机名:端口号/路径-->
                <!--content://quanziben:8080/openapp-->
                <data
                    android:scheme="content"
                    android:host="quanziben"
                    android:port="8080"
                    android:path="/openapp"/>

                <action android:name="android.intent.action.VIEW" />

                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />

            </intent-filter>


html如下:

<html>
      <head>
          <meta charset="utf-8" />
      <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1">          

      </head>
      <body>
        <a href="content://quanziben:8080/openapp" target="_self" id="taobao">打开全资本</a>

            <script type="text/javascript">
            function applink(){  
                return function(){  
                    var clickedAt = +new Date;  
                     setTimeout(function(){
                         !window.document.webkitHidden && setTimeout(function(){
                               if (+new Date - clickedAt < 2000){  
                                   window.location = 'http://www.quanziben.com';  
                               }  
                         }, 500);       
                     }, 500)   
                };  
            }  
            document.getElementById("taobao").onclick = applink();  
            document.getElementById("trip").onclick = applink();  
            </script>   
    </body>
</html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值