Set application default payment service

依然范特西╮ 提交于 2019-12-03 19:15:49

问题


Let's think about a case where user has installed multiple applications capable of NFC HCE payments. Those application services are visible under settings NFC Tap and Pay.

How to programmatically change your application to be the default payment service if it's not?

CardEmulation seems only to have API to query if service for category is default.

Thanks.


回答1:


The main idea behind having that UI is that the user can decide on which payment app should be the default app. Consequently, there is no way to programmatically set your app to be the default.

However, you can request the user to set your app as default app for the payment category (see 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);


来源:https://stackoverflow.com/questions/24164233/set-application-default-payment-service

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!