莫问天涯路几重,轻衫侧帽且从容。这篇文章主要讲述试图将Google Pay集成到我的Android应用中相关的知识,希望能为你提供帮助。
【试图将Google Pay集成到我的Android应用中】我正在尝试将Google Pay集成到我的android应用中。我正在追踪发现的this tutorial,但是当我运行代码时,却不断收到此错误E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.myapp.sqill, PID: 12555
android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=upi://pay?pa=your-merchant-vpa@xxx&
pn=your-merchant-name&
mc=your-merchant-code&
tr=your-transaction-ref-id&
tn=your-transaction-note&
am=your-order-amount&
cu=INR pkg=com.google.android.apps.nbu.paisa.user }
到目前为止是我的代码。在此先感谢
// PaymentPageActivity.java
Button pay_button;
final int UPI_PAYMENT=0;
Integer amount=5;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_payment_page);
pay_button=findViewById(R.id.pay);
//startActivitypay_button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
payUsingUpi();
}
});
}private void payUsingUpi() {Uri uri =
new Uri.Builder()
.scheme("upi")
.authority("pay")
.appendQueryParameter("pa", "your-merchant-vpa@xxx")
.appendQueryParameter("pn", "your-merchant-name")
.appendQueryParameter("mc", "your-merchant-code")
.appendQueryParameter("tr", "your-transaction-ref-id")
.appendQueryParameter("tn", "your-transaction-note")
.appendQueryParameter("am","$5.00")
.appendQueryParameter("cu", "INR").build();
String GOOGLE_PAY_PACKAGE_NAME = "com.android";
int GOOGLE_PAY_REQUEST_CODE = 123;
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(uri);
intent.setPackage(GOOGLE_PAY_PACKAGE_NAME);
startActivityForResult(intent, GOOGLE_PAY_REQUEST_CODE);
}
答案您可能使用了错误的软件包名称。根据以下example:
String GOOGLE_PAY_PACKAGE_NAME = "com.google.android.apps.nbu.paisa.user";
int GOOGLE_PAY_REQUEST_CODE = 123;
Uri uri =
new Uri.Builder()
.scheme("upi")
.authority("pay")
.appendQueryParameter("pa", "your-merchant-vpa@xxx")
.appendQueryParameter("pn", "your-merchant-name")
.appendQueryParameter("mc", "your-merchant-code")
.appendQueryParameter("tr", "your-transaction-ref-id")
.appendQueryParameter("tn", "your-transaction-note")
.appendQueryParameter("am", "your-order-amount")
.appendQueryParameter("cu", "INR")
.appendQueryParameter("url", "your-transaction-url")
.build();
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(uri);
intent.setPackage(GOOGLE_PAY_PACKAGE_NAME);
activity.startActivityForResult(intent, GOOGLE_PAY_REQUEST_CODE);
包裹名称应为
com.google.android.apps.nbu.paisa.user
。推荐阅读
- 使用Google Apps脚本搜索无结果
- 身份验证Apollo Graphql for android
- [android 8.0中的android套接字连接
- java.lang.IllegalStateException(找不到方法-初学者的Android编程书ERROR [duplicate])
- Android-如何在ActionBar中实现“赞”按钮
- 如何在Unity中使用由android studio制作的SQLite数据库()
- 要从Android设备删除图片吗()
- 当活动不在前面时,在Android中暂停CountDownTimer
- 如何在Symfony 3.3中为单个字段(文档实体)配置文件上传器