Android應用跳轉到微信和支付寶掃一掃

新版的微信已經把微信功能的schema都禁掉了,意味着咱們沒法打開微信的掃一掃等功能,目前正常的只能先進入微信(我測試的時候是微信版本7.0.3)已是很新的版本了android

具體調起微信掃一掃代碼以下,測試後確實是能夠使用的api

  @SuppressLint("WrongConstant")
    public static void toWeChatScanDirect(Context context) {
        try {
            Intent intent = new Intent();
            intent.setComponent(new ComponentName("com.tencent.mm", "com.tencent.mm.ui.LauncherUI"));
            intent.putExtra("LauncherUI.From.Scaner.Shortcut", true);
            intent.setFlags(335544320);
            intent.setAction("android.intent.action.VIEW");
            context.startActivity(intent);
        } catch (Exception e) {
        }
    }

具體調起支付寶掃一掃代碼以下,測試後確實是能夠使用的微信

public static void toAliPayScan(Context context)
    {
        try
        {
            Uri uri = Uri.parse("alipayqr://platformapi/startapp?saId=10000007");
            Intent intent = new Intent(Intent.ACTION_VIEW, uri);
            context.startActivity(intent);
        } catch (Exception e)
        {
            Toast.makeText(context, "打開失敗,請檢查是否安裝了支付寶", Toast.LENGTH_SHORT).show();
        }
    }

也歡迎你們一塊兒交流android掃一掃使用最高的掃碼組件是什麼,暫且我使用的是zbar,是android大神郭霖介紹的,zxing也是使用的,可是對比後發現zbar更快更穩定,附上一個zbar的測試demo程序代碼,參考附件app

相關文章
相關標籤/搜索