在使用Qt的Andr​​oid NFC实现 [英] NFC implementation on Android using Qt

查看:990
本文介绍了在使用Qt的Andr​​oid NFC实现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图读取NFC卡在Android上使用Qt的UID。
怡安一方面,经过一番研究,我发现在Java中,这类的读数。
在另一方面,我读过关于Qt文档如何调用和使用从Java静态对象 QAndroidJniObject :: callStaticObjectMethod ,但我不知道如何使用,以创建活动Qt的模块AndroidExtras,并当一个新的意图是它推出的通知。

I'm trying to read the UID from nfc card on Android using Qt. aOn one hand, After some research, I found this class in Java for the reading. On the other hand, I've read on Qt documentation how to call and static Object from Java using QAndroidJniObject::callStaticObjectMethod, but I have no idea how to create an activity using Qt's module AndroidExtras, and make it notify when a new Intent is launch.

有没有人有一些意见得到它的工作?
由于提前,

Does anyone have some advice to get it work? Thanks in advance,

推荐答案

更新:包括在其他的方式围绕信息

Update: Including info on the other way around

++ code调用C code是pretty简单,在Android NDK包括几个有用的例子其中最简单的招呼NDK,都可以在Eclipse被打开,但注意,您需要首先建立与NDK的构建JNI的一部分。关键的部分是让你的冠名权,我也跟着 HTTP :当我开始了//mindtherobot.com/blog/452/android-beginners-ndk-setup-step-by-step/ ,的的Andr​​oid NDK教程/指导初学者。有几个其他入门指南。

Compared to calling java from C/C++ code calling C code from java is pretty simple, the android ndk includes several useful examples the simplest being hello ndk, all can be opened in eclipse but note you need to build the jni part with ndk-build first. The key part is getting your naming right, I followed http://mindtherobot.com/blog/452/android-beginners-ndk-setup-step-by-step/ when i was starting out, Android NDK tutorial/guide for beginners. has several other start guides.

关键部件如下


  1. 创建你的java的活动,你可以继承QtActivity按照通知库。

  1. create your java activity, you can inherit QtActivity as per the notification library.

装入库(QT可能会处理这一步你)留出preciding lib和尾随的.so所以libstuff.so做如下

Load your library (Qt will probably handle this step for you) leave off the preciding lib and trailing .so so for libstuff.so do as below

// load the library - name matches jni/Android.mk
static {
   System.loadLibrary("stuff");
}


  • 从Java声明的C函数(确保名称相同,无论你在你的.c文件做任何类之外

  • Declare your C function from the java (make sure the name is the same as whatever you have in your .c file do this outside any classes

    private native String myCFunction();
    


  • 在某处你的java code调用myCFunction();

  • Somewhere in your java code call the myCFunction();

    String something = myCFunction();
    


  • 有一个Qt的例子,正是这样做的合理的文档
    http://doc.qt.io/qt-5/qtandroidextras-notification -example.html

    There is a Qt Example that does exactly this with reasonable documentation http://doc.qt.io/qt-5/qtandroidextras-notification-example.html

    相反然后直接从Qt的调用Java API NFC你可能想用Java编写的包装函数并调用从C ++应用程序。你可能也发现更容易从Java调用C ++的方法,结果特别是如果NFC库不imediatly返回结果。

    Rather then calling the java NFC api directly from Qt you may want to write a wrapper function in java and call that from your C++ application. You may well also find it easier to call a C++ method from java with the result especially if the NFC library doesn't return a result imediatly.

    甲骨文对有网站JNI概述和文档的 http://docs.oracle.com/javase/7/docs/technotes/guides/jni/spec/intro.html#wp725

    Oracle has a JNI overview and documentation on there website http://docs.oracle.com/javase/7/docs/technotes/guides/jni/spec/intro.html#wp725

    这篇关于在使用Qt的Andr​​oid NFC实现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆