1. 程式人生 > >Android應用識別支付寶收款二維碼直接跳轉支付寶轉賬介面

Android應用識別支付寶收款二維碼直接跳轉支付寶轉賬介面

我們知道應用可以通過scheme跳轉應用,支付寶的scheme

private static final String URL_FORMAT =
            "intent://platformapi/startapp?saId=10000007&" +
                    "clientVersion=3.7.0.0718&qrcode=https%3A%2F%2Fqr.alipay.com%2F{urlCode}%3F_s" +
                    "%3Dweb-other&_t=1472443966571#Intent;" + "scheme=alipayqr;package=com.eg.android.AlipayGphone;end";

這裡需要將{urlcode}替換為你識別的二維碼使用者的id

 public boolean startAlipay(Activity activity, String urlCode) {
        return startIntentUrl(activity, URL_FORMAT.replace("{urlCode}", urlCode));
    }
public boolean startIntentUrl(Activity activity, String intentUrl) {
        try {
            Intent intent = Intent.parseUri(intentUrl, Intent.URI_INTENT_SCHEME);
            activity.startActivity(intent);
        } catch (URISyntaxException e) {
            e.printStackTrace();
        } catch (ActivityNotFoundException e) {
            e.printStackTrace();
        }
    }