关于支付宝芝麻认证
查看支付宝官方文档:https://docs.open.alipay.com/271/dz10yd
关于芝麻的其他api可自行查询使用
https://docs.open.alipay.com/api_8/zhima.customer.certification.initialize
/**
* 启动支付宝进行认证
*
* @param url 开放平台返回的URL
*/
private void doVerify(String url) {
if (hasApplication()) {
Intent action = new Intent(Intent.ACTION_VIEW);
StringBuilder builder = new StringBuilder();
//appID不能变
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<ResolveInfo> list = manager.queryIntentActivities(action, PackageManager.GET_RESOLVED_FILTER);
return list != null && list.size() > 0;
}