问题描述
简而言之:
在Huawei Watch 2上,似乎已启用并启用了 NFC ,但 NFC_FEAUTURE 却未启用,因此nfc无法正常工作.
In short:
On the Huawei Watch 2 it seems like NFC is available and enabled but NFC_FEAUTURE is not, hence nfc is not working properly.
尝试开发在Huawei Watch 2上简单读取和显示NFC标签的功能会带来一些困难:
Trying to develop the ability to simply read and display NFC tags on the Huawei Watch 2 raises some difficulties:
mNfcAdapter.enableForegroundDispatch(this,nfcPendingIntent, nfcIntentFilter, null);
引发错误
java.lang.UnsupportedOperationException
这意味着FEATURE_NFC不可用.
在MainActivity onCreate()中:
That implies the FEATURE_NFC is not available.
In MainActivity onCreate():
mNfcAdapter = NfcAdapter.getDefaultAdapter(this); //NfcAdapter mNfcAdapter
if (mNfcAdapter != null) {
// Check if device supports NFC
Log.i("NFC","Your device supports NFC");
}
// Check if NFC is enabled
if (mNfcAdapter.isEnabled()) {
Log.i("NFC","NFC is Enabled");
}
if (getPackageManager().hasSystemFeature(PackageManager.FEATURE_NFC)) {
// Device compatible for NFC support
Log.i("NFC", "Device compatible for NFC support");
}
在控制台中显示
... I/NFC: Your device supports NFC
... I/NFC: NFC is Enabled
但不是
... I/NFC: Device compatible for NFC support
换句话说
mNfcAdapter !=null
和mNfcAdapter.isEnabled() == true
但(getPackageManager().hasSystemFeature(PackageManager.FEATURE_NFC) == false
这怎么可能?
顺便说一句.我的AndroidManifest.xml:
Btw. my AndroidManifest.xml:
<uses-permission android:name="android.permission.NFC"/>
<uses-feature android:name="android.hardware.nfc" android:required="true" />
另请参见 Android NFC教程和类似的帖子 NFC Android Wear(Huawei watch 2.0)
see also Android NFC Tutorial and a similar post NFC Android wear (Huawei watch 2.0)
我做错了什么?华为Watch 2上的NFC是否被锁定或禁用?
What am I doing wrong? Is NFC on the Huawei Watch 2 somehow locked or disabled?
预先感谢您的帮助.
推荐答案
基于此文档,华为手表2支持NFC功能,并且还具有Android Wear 2.0.
Based on this documentation, NFC feature is supported in Huawei Watch 2 and it also features Android Wear 2.0.
但是,错误 java.lang.UnsupportedOperationException
表示该方法尚未由框架作者实现,因此您可以与支持团队联系以进行澄清.参见此链接.
这篇关于Huawei Watch 2 NFC功能不可用?. Android Wear 2.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!