zoukankan      html  css  js  c++  java
  • Android 网页打开app(或者打开指定页面)并且接收参数

    网页打开app
    现实描述场景:
    1、短信通知中通知内容,比如信息中一个咨询详情,流程步骤,信息中的地址打开的是一个网页,网页打开就指定app或者app中的指定页面
    html代码

      <html>  
          
            <head>  
          
                <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">  
              
                <title>Insert title here</title>  
          
            </head>  
          
            <body>  
          
                <a href="m://任意规定,同intent-filter一致即可/?text=android">打开app</a><br/>  
          
            </body>  
          
        </html>  

    然后再app的AndroidManifest.xml中配置代码,如果只想打开app即在app的启动页面即可,如果想要再指定页面打开并且接收参数,再对应的activity中配置intent-filter

    <activity android:name="指定页面">
                <intent-filter>
                    <action android:name="android.intent.action.VIEW" />
    
                    <category android:name="android.intent.category.DEFAULT" />
                    <category android:name="android.intent.category.BROWSABLE" />
    
                    <data
                        android:host="任意规定,同intent-filter一致即可"
                        android:scheme="m" />
                </intent-filter>
            </activity>

    接收参数操作再app的onCreate中

     //测试获取网页打开app传递的参数
            Uri uri=getIntent().getData();
            if (uri!=null){
                //获取传递的参数
                Toast.makeText(mContext, "网页传递的参数:"+uri.getQueryParameter("text"), Toast.LENGTH_SHORT).show();
                Log.e("qzinfodetails","-------------网页传递的参数:"+ uri.getQueryParameter("text"));
            }
        }

    这样即可打开指定页面并且接收参数

  • 相关阅读:
    ES分页
    在github上使用workflow构建docker镜像并推送阿里云
    xxl-job滥用netty导致的问题和解决方案
    使用netty实现socks5协议
    docker日志设置
    关于我
    友情链接
    分布式任务调度系统:xxl-job
    SpringBoot自定义配置以及IDEA配置提示
    frp穿透内网使用vsftpd服务
  • 原文地址:https://www.cnblogs.com/dingxiansen/p/10670749.html
Copyright © 2011-2022 走看看