我正在Nexus 7平板电脑上部署应用程序,并尝试使用支持NFC的Nexus 5.
我被困在这里,因为我在调试模式下的应用程序告诉我NFC不可用。
这是我的代码:
manager = new QNearFieldManager(this);
if(manager->isAvailable())
{
qDebug() << " Nfc is availiable";
}
else
{
qDebug() << " Nfc is not availiable";
qWarning() << "NFC not available";
}
manager->setTargetAccessModes(QNearFieldManager::NdefReadTargetAccess);
manager->registerNdefMessageHandler(this, SLOT(handleNdefMessage(QNdefMessage,QNearFieldTarget*)));
connect(manager,SIGNAL(targetDetected(QNearFieldTarget*)),this,SLOT(nfcTargetDetected(QNearFieldTarget*)));
connect(manager,SIGNAL(targetLost(QNearFieldTarget*)),this, SLOT(nfcTargetLost(QNearFieldTarget*)));
if (!manager->startTargetDetection()) {
qWarning() << "NFC target detection could not be started";
}
我的专业文件内容:
QT += core gui nfc
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = NFC_Research
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp
HEADERS += mainwindow.h
FORMS += mainwindow.ui
ANDROID_PACKAGE_SOURCE_DIR = $$PWD/android
DISTFILES += \
android/AndroidManifest.xml
我在这里缺少什么?