主要採用intent意圖匹配間接實現檢測支付寶客戶端是否安裝,代碼如下:
public static boolean checkAliPayInstalled(Context context) { Uri uri = Uri.parse("alipays://platformapi/startApp"); Intent intent = new Intent(Intent.ACTION_VIEW, uri); ComponentName componentName = intent.resolveActivity(context.getPackageManager()); return componentName != null; }
目前測試有效