zoukankan      html  css  js  c++  java
  • 微信weixin://xxx 分析

    通过weixin://来打开微信客户端:

    <a href="weixin://">打开微信</a>
    <a href="weixin://dl/business/?ticket=xxx">微信内打开网页</a>

     协会说明:

    微信跳转入口:

    通过反编译,看到weixin://协议的入口定义为WXCustomSchemeEntryActivity,那就是浏览器访问以weixin为scheme的请求时就会打开微信内的WXCustomSchemeEntryActivity

    <activity
       android:name="com.tencent.mm.plugin.base.stub.WXCustomSchemeEntryActivity"
        android:configChanges="keyboardHidden|orientation|screenSize"
        android:excludeFromRecents="true"
        android:exported="true"
        android:launchMode="singleTop"
        android:taskAffinity=".wxpayentry"
        android:theme="@style/mm">
        <intent-filter>
            <data android:scheme="weixin" />
            <action android:name="android.intent.action.VIEW" />
    
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
        </intent-filter>
    </activity>

    内部处理

    1.获取携带数据

    Uri data = getIntent().getData();
    
    if (data != null) {
        String scheme = data.getScheme();
        String host = data.getHost();
        String query = data.getQuery();
    
        Log.i("MicroMsg.WXCustomSchemeEntryActivity", String.format("uri is %s,scheme is %s, host is %s, query is %s", data.toString(), scheme, host, query));
    }

    2.判断是否合法

    // 校验是否非法
    if (data != null) {
        String uri = data.getScheme() + "://" + data.getHost() + data.getPath();
        // qby详情看问末附录
        if (!qby.containsKey(uri) && !data.toString().startsWith("weixin://dl/business")) {
           return;
        }
    }

    3.进行跳转

    根据url对应的地址,调用微信内的路由组件进行跳转。

    所有协议

    HashMap qyb = new HashMap();
    qyb.put("weixin://", 0L);
    qyb.put("weixin://dl/stickers", 1L);
    qyb.put("weixin://dl/games", 2L);
    qyb.put("weixin://dl/moments", 4L);
    qyb.put("weixin://dl/add", 8L);
    qyb.put("weixin://dl/shopping", 16L);
    qyb.put("weixin://dl/groupchat", 32L);
    qyb.put("weixin://dl/scan", 64L);
    qyb.put("weixin://dl/profile", 128L);
    qyb.put("weixin://dl/settings", 256L);
    qyb.put("weixin://dl/general", 512L);
    qyb.put("weixin://dl/help", 1024L);
    qyb.put("weixin://dl/notifications", 2048L);
    qyb.put("weixin://dl/terms", 4096L);
    qyb.put("weixin://dl/chat", 8192L);
    qyb.put("weixin://dl/features", 16384L);
    qyb.put("weixin://dl/clear", 32768L);
    qyb.put("weixin://dl/feedback", 65536L);
    qyb.put("weixin://dl/faq", 131072L);
    qyb.put("weixin://dl/recommendation", 262144L);
    qyb.put("weixin://dl/groups", 524288L);
    qyb.put("weixin://dl/tags", 1048576L);
    qyb.put("weixin://dl/officialaccounts", 2097152L);
    qyb.put("weixin://dl/posts", 4194304L);
    qyb.put("weixin://dl/favorites", 8388608L);
    qyb.put("weixin://dl/privacy", 16777216L);
    qyb.put("weixin://dl/security", 33554432L);
    qyb.put("weixin://dl/wallet", 67108864L);
    qyb.put("weixin://dl/businessPay", 134217728L);
    qyb.put("weixin://dl/businessPay/", 134217728L);
    qyb.put("weixin://dl/wechatout", 268435456L);
    qyb.put("weixin://dl/protection", 1073741824L);
    qyb.put("weixin://dl/card", 2147483648L);
    qyb.put("weixin://dl/about", 1125899906842624L);
    qyb.put("weixin://dl/blacklist", 4294967296L);
    qyb.put("weixin://dl/textsize", 8589934592L);
    qyb.put("weixin://dl/sight", 17179869184L);
    qyb.put("weixin://dl/languages", 34359738368L);
    qyb.put("weixin://dl/chathistory", 68719476736L);
    qyb.put("weixin://dl/bindqq", 137438953472L);
    qyb.put("weixin://dl/bindmobile", 274877906944L);
    qyb.put("weixin://dl/bindemail", 549755813888L);
    qyb.put("weixin://dl/securityassistant", 1099511627776L);
    qyb.put("weixin://dl/broadcastmessage", 2199023255552L);
    qyb.put("weixin://dl/setname", 4398046511104L);
    qyb.put("weixin://dl/myQRcode", 8796093022208L);
    qyb.put("weixin://dl/myaddress", 17592186044416L);
    qyb.put("weixin://dl/hidemoments", 35184372088832L);
    qyb.put("weixin://dl/blockmoments", 70368744177664L);
    qyb.put("weixin://dl/stickersetting", 140737488355328L);
    qyb.put("weixin://dl/log", 281474976710656L);
    qyb.put("weixin://dl/wechatoutcoupon", 562949953421312L);
    qyb.put("weixin://dl/wechatoutshare", 18014398509481984L);
    qyb.put("weixin://dl/personalemoticon", 4503599627370496L);
    qyb.put("weixin://dl/designeremoji", 9007199254740992L);
    qyb.put("weixin://dl/sightdraft", 576460752303423488L);
    qyb.put("weixin://dl/jumpWxa/", 576460752303423489L);
    qyb.put("weixin://dl/offlinepay/", 576460752303423490L);
  • 相关阅读:
    leetcode Super Ugly Number
    leetcode Find Median from Data Stream
    leetcode Remove Invalid Parentheses
    leetcode Range Sum Query
    leetcode Range Sum Query
    leetcode Minimum Height Trees
    hdu 3836 Equivalent Sets
    hdu 1269 迷宫城堡
    hud 2586 How far away ?
    poj 1330 Nearest Common Ancestors
  • 原文地址:https://www.cnblogs.com/feixiablog/p/10755933.html
Copyright © 2011-2022 走看看