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

相关文章
相关标签/搜索