设置应用默认支付服务

Nik*_*iko 6 android nfc hce android-tap-and-pay

让我们考虑用户安装了多个能够进行NFC HCE支付的应用程序的情况.这些应用程序服务在NFC Tap and Pay设置下可见.

如果不是,如何以编程方式将您的应用程序更改为默认支付服务?

CardEmulation 似乎只有API来查询类别的服务是否为默认值.

谢谢.

Mic*_*and 11

拥有该UI的主要思想是用户可以决定哪个支付应用程序应该是默认应用程序.因此,无法编程方式将您的应用程序设置为默认值.

但是,您可以请求用户将您的应用设置为付款类别的默认应用(请参阅ACTION_CHANGE_DEFAULT):

Intent intent = new Intent();
intent.setAction(CardEmulation.ACTION_CHANGE_DEFAULT);
intent.putExtra(CardEmulation.EXTRA_SERVICE_COMPONENT,
                new ComponentName(this, my.package.MyPaymentService.class));
intent.putExtra(CardEmulation.EXTRA_CATEGORY, CardEmulation.CATEGORY_PAYMENT);

startActivity(intent);
Run Code Online (Sandbox Code Playgroud)