如何检查NFC是否已启用的机器人? [英] How to check whether NFC is enabled or not in android?
本文介绍了如何检查NFC是否已启用的机器人?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我如何检查NFC是否已启用编程?有没有办法从我的程序在设备上启用NFC?请帮我
解决方案
NfcManager经理=(NfcManager)context.getSystemService(Context.NFC_SERVICE);
NfcAdapter适配器= manager.getDefaultAdapter();
如果(适配器= NULL和放大器;!&安培; adapter.isEnabled()){
//适配器存在且已启用。
}
您不能启用NFC编程。用户必须通过设置或硬件按钮手动完成。
How can i check whether NFC is enabled or not programmatically? Is there any way to enable the NFC on the device from my program? Please help me
解决方案
NfcManager manager = (NfcManager) context.getSystemService(Context.NFC_SERVICE);
NfcAdapter adapter = manager.getDefaultAdapter();
if (adapter != null && adapter.isEnabled()) {
// adapter exists and is enabled.
}
You cannot enable the NFC programmatically. The user has to do it manually through settings or hardware button.
这篇关于如何检查NFC是否已启用的机器人?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文