首先 -
我知道有一个类似的问题可以解答。然而,答案并没有帮助我。
我的问题是一样的 -
使用UPI url如下
String UPI = "upi://pay?pa=xsas@hdfcbank&pn=ABC+DEF&mc=qy67vt&tr=12121&tn=your+order+with+us&am=1.5&url=shopify.com";
Intent intent = new Intent();
intent.setAction(Intent.ACTION_SEND);
intent.setData(Uri.parse(UPI));
Intent chooser = Intent.createChooser(intent, "Pay with...");
startActivityForResult(chooser, 1, null);
在我使用setData的那一刻,我停止获取可与之共享的应用程序列表(列表为空)。如果我删除setData,常规的应用程序列表(短信,电子邮件等)开始弹出,银行应用程序(接受UPI,比如ICICI / HDFC)不是其中之一。
这里可能出现什么问题?,
替换这个:
String UPI = "upi://pay?pa=xsas@hdfcbank&pn=ABC+DEF&mc=qy67vt&tr=12121&tn=your+order+with+us&am=1.5&url=shopify.com";
Intent intent = new Intent();
intent.setAction(Intent.ACTION_SEND);
intent.setData(Uri.parse(UPI));
Intent chooser = Intent.createChooser(intent, "Pay with...");
startActivityForResult(chooser, 1, null);
有了这个:
String UPI = "upi://pay?pa=xsas@hdfcbank&pn=ABC+DEF&mc=qy67vt&tr=12121&tn=your+order+with+us&am=1.5&url=shopify.com";
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW); // this line needs to be updated
intent.setData(Uri.parse(UPI));
Intent chooser = Intent.createChooser(intent, "Pay with...");
startActivityForResult(chooser, 1, null);
这是因为对于所有深度链接的upi应用程序来处理传入的意图,需要使用View Action调用它们。
您可以从您的意图中省略intent.setAction(Intent.ACTION_SEND);
部分,因为这不是强制性的,不同的应用程序将处理不同的操作。
正如你在原始问题中看到的,你提到的没有setAction