支付宝人脸认证(安卓)

    技术2022-07-11  242

    支付宝人脸认证

    支付宝人脸认证后端接入前端的实现

    /** * 启动支付宝进行认证 * @param url 开放平台返回的URL */ private void doVerify(String url) { if (hasApplication()) { Intent action = new Intent(Intent.ACTION_VIEW); StringBuilder builder = new StringBuilder(); // 这里使用固定appid 20000067 builder.append("alipays://platformapi/startapp?appId=20000067&url="); builder.append(URLEncoder.encode(url)); action.setData(Uri.parse(builder.toString())); startActivity(action); } else { // 处理没有安装支付宝的情况 new AlertDialog.Builder(this) .setMessage("是否下载并安装支付宝完成认证?") .setPositiveButton("好的", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Intent action = new Intent(Intent.ACTION_VIEW); action.setData(Uri.parse("https://m.alipay.com")); startActivity(action); } }).setNegativeButton("算了", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }).show(); } } /** * 判断是否安装了支付宝 * @return true 为已经安装 */ private boolean hasApplication() { PackageManager manager = getPackageManager(); Intent action = new Intent(Intent.ACTION_VIEW); action.setData(Uri.parse("alipays://")); List list = manager.queryIntentActivities(action, PackageManager.GET_RESOLVED_FILTER); return list != null && list.size() > 0; } <!-- 用来认证完成返回的界面 --> <activity android:name=".CertificationActivity" android:launchMode="singleTask"> <intent-filter> <!-- 随便设置 --> <data android:host="name" android:path="/path" android:scheme="scheme" /> <!-- 下面这几行必须得设置 --> <category android:name="android.intent.category.DEFAULT" /> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.BROWSABLE" /> </intent-filter> </activity>
    Processed: 0.016, SQL: 9