1. 调用 NfcController 类的 getInstance()接口,获取 NfcController 实例。
2. 调用 CardEmulation 类的 getInstance(mNfcController)接口,获取CardEmulation 实例,去管理本机卡模拟模块操作。xpanx.com
3. 调用 registerForegroundPreferred()接口去动态设置前台优先应用。
4. 调用 unregisterForegroundPreferred()接口去取消设置前台优先应用。
// 获取 NFC 控制对象
NfcController mNfcController = NfcController.getInstance(context);
// 获取卡模拟控制对象
CardEmulation mCardEmulation =
CardEmulation.getInstance(mNfcController);
// 动态设置前台优先应用
mCardEmulation.registerForegroundPreferred(new Ability(), new
ElementName());
// 注销前台优先应用
mCardEmulation.unregisterForegroundPreferred(new Ability());
https://xpanx.com/
评论