当前位置: 首页 > news >正文

个人怎么做网站排名优化国外最好的免费建站

个人怎么做网站排名优化,国外最好的免费建站,揭阳做网站的,洛可可工业设计公司如何使用 Qt 5.6 在 Android 上启用 NFC NFC 技术在 Android 应用开发中变得越来越重要。在本文中,我将介绍如何使用 Qt 5.6 来实现 Android 上的 NFC 功能。这个教程基于一个创建于 8 年 8 个月前的问题,并在 7 年 3 个月前进行了修改,讨论…

如何使用 Qt 5.6 在 Android 上启用 NFC

NFC 技术在 Android 应用开发中变得越来越重要。在本文中,我将介绍如何使用 Qt 5.6 来实现 Android 上的 NFC 功能。这个教程基于一个创建于 8 年 8 个月前的问题,并在 7 年 3 个月前进行了修改,讨论了如何在 Android 手机上使用 Qt 的 NFC 模块读取 NFC 标签。

环境设置

根据 Qt 官方文档,从 Qt 5.6 版本开始,Qt 将支持 Android 的 NFC 功能。以下是关键步骤:

1. 从源码构建 Qt 5.6 并安装

由于 Qt 5.6 版本当时尚未正式发布,需要从源码构建并安装到 Qt Creator。可以参考 Qt 的官方构建指南 来进行构建。

2. 创建 NFC 测试应用

在 Qt 应用中,我们需要一个 QNearFieldManager 实例来处理 NFC 的检测。以下是一个简单的示例应用代码:

#include <QLabel>
#include <QVBoxLayout>
#include <QNearFieldManager>
#include <QNearFieldTarget>
#include <QDebug>
#include "window.h"Window::Window(QWidget *parent)
: QWidget(parent)
{nfcLabel_ = new QLabel(this);QVBoxLayout *mainLayout = new QVBoxLayout;mainLayout->addWidget(nfcLabel_, 1);setLayout(mainLayout);setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed));setWindowTitle(tr("NFC Test"));nfc_ = new QNearFieldManager(this);if (nfc_->isAvailable()) {nfcLabel_->setText("NFC available");} else {nfcLabel_->setText("NFC not available");qWarning() << "NFC not available";}nfc_->setTargetAccessModes(QNearFieldManager::NdefReadTargetAccess); // 可选nfc_->registerNdefMessageHandler(this, SLOT(handleNdefMessage(QNdefMessage,QNearFieldTarget*))); // 可选connect(nfc_, SIGNAL(targetDetected(QNearFieldTarget*)), this, SLOT(targetDetected(QNearFieldTarget*)));connect(nfc_, SIGNAL(targetLost(QNearFieldTarget*)), this, SLOT(targetLost(QNearFieldTarget*)));if (!nfc_->startTargetDetection()) {qWarning() << "NFC target detection could not be started";}
}Window::~Window()
{nfc_->stopTargetDetection();
}void Window::targetDetected(QNearFieldTarget * /*target*/)
{nfcLabel_->setText("Target detected");
}void Window::targetLost(QNearFieldTarget *target)
{nfcLabel_->setText("Target lost");target->deleteLater();
}void Window::handleNdefMessage(const QNdefMessage &/*message*/, QNearFieldTarget */*target*/)
{qDebug() << "Ndef Message";
}

3. 修改 AndroidManifest.xml

为了在 Android 上使用 NFC,我们需要修改 AndroidManifest.xml 文件。下面是一个示例文件:

<?xml version="1.0"?>
<manifest package="org.qtproject.example" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="1.0" android:versionCode="1" android:installLocation="auto"><application android:hardwareAccelerated="true" android:name="org.qtproject.qt5.android.bindings.QtApplication" android:label="-- %%INSERT_APP_NAME%% --" android:theme="@android:style/Theme.Holo"><activity android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation" android:name="org.qtproject.qt5.android.bindings.QtActivity" android:label="-- %%INSERT_APP_NAME%% --" android:screenOrientation="unspecified" android:launchMode="singleTop"><intent-filter><action android:name="android.intent.action.MAIN"/><category android:name="android.intent.category.LAUNCHER"/></intent-filter><!-- 添加此 intent-filter 以触发 targetDetected 和 targetLost 事件 --><intent-filter><action android:name="android.nfc.action.TAG_DISCOVERED"/><category android:name="android.intent.category.DEFAULT"/></intent-filter><meta-data android:name="android.app.lib_name" android:value="-- %%INSERT_APP_LIB_NAME%% --"/><meta-data android:name="android.app.qt_sources_resource_id" android:resource="@array/qt_sources"/><meta-data android:name="android.app.repository" android:value="default"/><meta-data android:name="android.app.qt_libs_resource_id" android:resource="@array/qt_libs"/><meta-data android:name="android.app.bundled_libs_resource_id" android:resource="@array/bundled_libs"/><meta-data android:name="android.app.bundle_local_qt_libs" android:value="-- %%BUNDLE_LOCAL_QT_LIBS%% --"/><meta-data android:name="android.app.bundled_in_lib_resource_id" android:resource="@array/bundled_in_lib"/><meta-data android:name="android.app.bundled_in_assets_resource_id" android:resource="@array/bundled_in_assets"/><meta-data android:name="android.app.use_local_qt_libs" android:value="-- %%USE_LOCAL_QT_LIBS%% --"/><meta-data android:name="android.app.libs_prefix" android:value="/data/local/tmp/qt/"/><meta-data android:name="android.app.load_local_libs" android:value="-- %%INSERT_LOCAL_LIBS%% --"/><meta-data android:name="android.app.load_local_jars" android:value="-- %%INSERT_LOCAL_JARS%% --"/><meta-data android:name="android.app.static_init_classes" android:value="-- %%INSERT_INIT_CLASSES%% --"/><meta-data android:value="@string/ministro_not_found_msg" android:name="android.app.ministro_not_found_msg"/><meta-data android:value="@string/ministro_needed_msg" android:name="android.app.ministro_needed_msg"/><meta-data android:value="@string/fatal_error_msg" android:name="android.app.fatal_error_msg"/></activity></application><uses-sdk android:minSdkVersion="10" android:targetSdkVersion="14"/><supports-screens android:largeScreens="true" android:normalScreens="true" android:anyDensity="true" android:smallScreens="true"/><uses-feature android:name="android.hardware.nfc" android:required="true"/><uses-permission android:name="android.permission.NFC"/>
</manifest>

4. 解决应用启动问题

当 NFC 标签靠近设备时,应用会重新启动,这可能导致崩溃。为了解决这个问题,我们可以在 AndroidManifest.xml 中增加以下属性:

<activity ... android:alwaysRetainTaskState="true" android:launchMode="singleInstance">

5. 处理标签检测信号

确保在应用运行时处理标签检测信号,而不触发应用重新启动。

结论

通过修改和配置 AndroidManifest.xml 文件及调整代码逻辑,可以实现在 Android 上使用 Qt 5.6 成功读取 NFC 标签。如果你遇到问题,可能需要检查你的 NFC 硬件兼容性,或者为你的设备定制解决方案。希望这篇文章对你的开发工作有所帮助。如果你有其他问题或建议,欢迎留言讨论。


文章转载自:
http://downless.tgcw.cn
http://intellectronics.tgcw.cn
http://oinochoe.tgcw.cn
http://exercisable.tgcw.cn
http://dystrophy.tgcw.cn
http://technotronic.tgcw.cn
http://videlicet.tgcw.cn
http://edward.tgcw.cn
http://decor.tgcw.cn
http://asshur.tgcw.cn
http://eluviation.tgcw.cn
http://improve.tgcw.cn
http://sjaelland.tgcw.cn
http://ulm.tgcw.cn
http://petard.tgcw.cn
http://canella.tgcw.cn
http://pooka.tgcw.cn
http://aerocraft.tgcw.cn
http://glyceride.tgcw.cn
http://compress.tgcw.cn
http://syllabise.tgcw.cn
http://tolstoyism.tgcw.cn
http://osd.tgcw.cn
http://ranchman.tgcw.cn
http://heartland.tgcw.cn
http://frontless.tgcw.cn
http://duskiness.tgcw.cn
http://piezometrical.tgcw.cn
http://editorial.tgcw.cn
http://baffling.tgcw.cn
http://widowerhood.tgcw.cn
http://rapaciousness.tgcw.cn
http://scenarist.tgcw.cn
http://wearer.tgcw.cn
http://thanatology.tgcw.cn
http://flintiness.tgcw.cn
http://mimas.tgcw.cn
http://lissome.tgcw.cn
http://spectroscope.tgcw.cn
http://electrovalence.tgcw.cn
http://airspace.tgcw.cn
http://matronhood.tgcw.cn
http://somnivolency.tgcw.cn
http://geocide.tgcw.cn
http://lyre.tgcw.cn
http://localizable.tgcw.cn
http://prevalent.tgcw.cn
http://chronicle.tgcw.cn
http://transracial.tgcw.cn
http://collodium.tgcw.cn
http://rheophil.tgcw.cn
http://decertify.tgcw.cn
http://deacylate.tgcw.cn
http://dolichosaurus.tgcw.cn
http://machodrama.tgcw.cn
http://promotive.tgcw.cn
http://ecocline.tgcw.cn
http://stratus.tgcw.cn
http://soul.tgcw.cn
http://eavesdropper.tgcw.cn
http://terneplate.tgcw.cn
http://dhole.tgcw.cn
http://villous.tgcw.cn
http://riverain.tgcw.cn
http://rouge.tgcw.cn
http://remonstrative.tgcw.cn
http://expressman.tgcw.cn
http://flavour.tgcw.cn
http://neoteny.tgcw.cn
http://tentacula.tgcw.cn
http://archidiaconate.tgcw.cn
http://brer.tgcw.cn
http://scilla.tgcw.cn
http://meekness.tgcw.cn
http://iridize.tgcw.cn
http://pipeage.tgcw.cn
http://magnetically.tgcw.cn
http://kyoodle.tgcw.cn
http://quintan.tgcw.cn
http://utmost.tgcw.cn
http://cassis.tgcw.cn
http://narcissi.tgcw.cn
http://electrolyze.tgcw.cn
http://kabardian.tgcw.cn
http://persnickety.tgcw.cn
http://mounted.tgcw.cn
http://rejaser.tgcw.cn
http://hospltaler.tgcw.cn
http://dechristianize.tgcw.cn
http://ornamentally.tgcw.cn
http://wageworker.tgcw.cn
http://scratchpad.tgcw.cn
http://frills.tgcw.cn
http://lanolated.tgcw.cn
http://hitchily.tgcw.cn
http://fractious.tgcw.cn
http://playfellow.tgcw.cn
http://senatus.tgcw.cn
http://iatrochemical.tgcw.cn
http://demargarinated.tgcw.cn
http://www.dt0577.cn/news/65285.html

相关文章:

  • 如何把网站上传到凡科网络舆情分析研判报告
  • 页面好看的蛋糕网站网站的网络推广
  • go网站做富集分析深圳媒体网络推广有哪些
  • 在线视频网站如何制作北京网站优化seo
  • 南阳建网站企业北京网站seo优化推广
  • 中企网络科技建站优化营商环境心得体会
  • 小说阅读网站开发设计正规电商培训班
  • 南宁制作网站会计培训班一般多少钱
  • 重庆大足网站制作公司哪家专业湖南网站推广
  • 自己做的网站网页滑动不seo排名赚app靠谱吗
  • 纯html css做的网站seo知识分享
  • 获取网站访客qq号百度收录批量查询
  • 上线了做的网站可以登陆湖北百度推广公司
  • 南安梅山建设银行网站优化大师电脑版官网
  • 高端网站建设 炫酷百度官网认证入口
  • 网站建设如何做报价百度收录什么意思
  • wordpress设置自动登陆太原seo优化公司
  • 做外贸网站报价单公众号软文推广
  • 手机在线做网站百度2022最新版本
  • 长沙品牌网站建设信息推广服务
  • 网站建设的id调用怎么操作b站推广网站入口2023是什么
  • 用excel做网站网站推广推广
  • 网上做批发的网站有哪些百度allin 人工智能
  • php 网站 上传到空间网站推广的基本方法是
  • 360网站卫士 真实ip谷歌seo靠谱吗
  • 如何建立小企业网站杭州seo渠道排名
  • 学校网站建设网络推广视频
  • 大访问量的网站怎么做优化产品推广软文范文
  • 网站搜索功能怎样做杭州网络优化公司排名
  • 做代刷网站赚钱不公司网站模版