[英]Disable Android Beam and NFC
I want to disable Android Beam when my NFC activity that implements CreateNdefMessageCallback is not in the foreground. 当我实现CreateNdefMessageCallback的NFC活动不在前台时,我想禁用Android Beam。 Currently I use when the activity loses focus:
当前,我在活动失去重点时使用:
if(mNFCAdapter!=null)
{
mNFCAdapter.disableForegroundDispatch(this);
mNFCAdapter.setNdefPushMessage(null, this);
mNFCAdapter.setNdefPushMessageCallback(null, this);
}
However, every activity in my application still starts the Beam when a NFC device is discovered. 但是,发现NFC设备后,应用程序中的每个活动仍会启动Beam。
Any alternative methods? 还有其他方法吗?
In all activities in which you want to disable Android Beam add to onCreate()
: 在要禁用Android Beam的所有活动中,将其添加到
onCreate()
:
if(mNFCAdapter!=null) {
mNFCAdapter.setNdefPushMessage(null, this);
mNFCAdapter.setNdefPushMessageCallback(null, this); // optional
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.