我正在尝试使用Android IONIC(Javascript)应用程序中的UPI付款
我得到以下异常
android.content.ActivityNotFoundException:找不到处理意图的活动 {act = android.intent.action.SEND dat = upi:// pay?pa = recipient @ hdfc& pn = recipient_name& am = 102.00& tn = Test_Transaction}
01-10 21:58:32.334 E / PluginManager(29853):at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1792)
01-10 21:58:32.334 E / PluginManager(29853):at android.app.Instrumentation.execStartActivity(Instrumentation.java:1512)
我的设备上有3个支持UPI的应用程序:来自Yes bank的BHIM和PhonePe以及来自ICICI的iMobile
这是一段代码
window.plugins.webintent.startActivity({
action: window.plugins.webintent.ACTION_VIEW,
url: upiUrl
},
function()
{
console.log("After calling startActivity");
},
function() {
console.log("Failed to open URL via Android Intent. URL: " + upiUrl)
}
);
答案 0 :(得分:0)
您可以创建自定义插件并使用Intent代码。以下是我为Expense Sharing Cordova App撰写的代码。你可以使它适合IONIC。
cordova.getThreadPool().execute(new Runnable() {
@Override
public void run() {
if(Build.VERSION.SDK_INT<16){
callbackContext.error("This feature is available only for Android version Jelly Bean and higher");
return;
}
try {
JSONObject jo = data.getJSONObject(0);
String upi_vpa = jo.getString("upi_vpa");
String name = jo.getString("name");
String UPI = "upi://pay?pa="+upi_vpa+"&pn="+name+"&tn=#Repay-GCF&cu=INR";
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setData(Uri.parse(UPI));
Intent chooser = Intent.createChooser(intent, "Send Money with...");
cordova.getActivity().startActivityForResult(chooser, MainActivity.UPI_PAY_REQUEST, null);
}catch (JSONException e){
e.printStackTrace();
}
}
});