我正在创建 Xamarin Android 应用程序。我有一个只接受 UPI 付款的功能。我面临的问题是,它适用于某些设备,但适用于少数设备。我已经用 Realme X2 (Working) 和 Redmi Note 8 (Not working) 进行了测试。
最初它在几天前为 Redmi Note 8 工作。现在 Google Pay 和 Device 都有更新,但现在无法正常工作。但同样适用于具有相同场景的 Realme X2。
它引发如下异常。
{Android.Content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=upi://pay?pa=xxxxxxx@okhdfcbank&pn=XYZStoreStore&tn=20041901232493241&am=1.00&cu=INR pkg=com.google.android.apps.nbu.paisa.user }
at Java.Interop.JniEnvironment+InstanceMethods.CallNonvirtualVoidMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniObjectReference type, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x0008e] in <26521a5118b44c858c385715922b9d5d>:0
at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualVoidMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x0005d] in <26521a5118b44c858c385715922b9d5d>:0
at Android.App.Activity.StartActivityForResult (Android.Content.Intent intent, System.Int32 requestCode) [0x00044] in <4ccdb3137d974856b786e1aeebbfbab6>:0
at WalletActivity.PayWithGPay (Models.Wallet wallet) [0x000c2] in \WalletActivity.cs:302
--- End of managed Android.Content.ActivityNotFoundException stack trace ---
android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=upi://pay?pa=xxxxxxx@okhdfcbank&pn=XYZStoreStore&tn=20041901232493241&am=1.00&cu=INR pkg=com.google.android.apps.nbu.paisa.user }
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:2016)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1677)
at android.app.Activity.startActivityForResult(Activity.java:4652)
at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:767)
at android.app.Activity.startActivityForResult(Activity.java:4610)
at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:754)
at mono.android.view.View_OnClickListenerImplementor.n_onClick(Native Method)
at mono.android.view.View_OnClickListenerImplementor.onClick(View_OnClickListenerImplementor.java:30)
at android.view.View.performClick(View.java:6608)
at android.view.View.performClickInternal(View.java:6585)
at android.view.View.access$3100(View.java:785)
at android.view.View$PerformClick.run(View.java:25921)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:201)
at android.app.ActivityThread.main(ActivityThread.java:6864)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873)
这是我的代码:
private static string GOOGLE_TEZ_PACKAGE_NAME = "com.google.android.apps.nbu.paisa.user";
private static int TEZ_REQUEST_CODE = 123;
try
{
if (wallet.WalletAmount > 0)
{
RefrenceID = AndroidHelper.GetReferenceID();
Android.Net.Uri uri =
new Android.Net.Uri.Builder()
.Scheme("upi")
.Authority("pay")
.AppendQueryParameter("pa", "xxxxxxx@okhdfcbank")
.AppendQueryParameter("pn", "XYZStore")
//.AppendQueryParameter("mc", "1234")
//.AppendQueryParameter("tr", DateTime.Now.ToString("yyyyMMddhhmmss"))
.AppendQueryParameter("tn", RefrenceID)
.AppendQueryParameter("am", WalletAmount)
.AppendQueryParameter("cu", "INR")
.Build();
Intent intent = new Intent(Intent.ActionView);
intent.SetData(uri);
intent.SetPackage(GOOGLE_TEZ_PACKAGE_NAME);
StartActivityForResult(intent, TEZ_REQUEST_CODE);
// Intent upiPayIntent = new Intent(Intent.ActionView);
// upiPayIntent.SetData(uri);
// Intent chooser = Intent.CreateChooser(upiPayIntent, "Pay with");
// if (null != chooser.ResolveActivity(this.PackageManager))
// StartActivityForResult(chooser, TEZ_REQUEST_CODE);
// else
// Toast.MakeText(this, "No UPI app found, please install one to continue", ToastLength.Long).Show();
}
}
catch (Android.Content.ActivityNotFoundException ex)
{
Toast.MakeText(this, "Google Pay application not found, kindly Install", ToastLength.Long).Show();
}
catch (Exception ex)
{
Toast.MakeText(this, "Exception Occured - E1002", ToastLength.Long).Show();
}
请帮助我解决问题。