PDA

View Full Version : QT in Android -- Example for accessing the GPS Service



qlands
18th May 2011, 08:11
Hi,

Note: This application uses Necessitas that is a QT Lighthouse port to Android devices by BogDan Vatra. Please find all what you need to build the example here: http://sourceforge.net/p/necessitas/home/

Now,

After two weeks of intense headaches I finally got a QT application to use the Android GPS service and have location readings.

You can access it from: www.qlands.com/other_files/Android_GPS.tar.gz

PLEASE read the README_ME_FIRST_OR_IT_WILL_NOT_WORK file before you get too excited!

For BogDan Vatra et al.:
I had to make some slight changes to:
1- qtmain_android.cpp
2- QtApplication.java

And I sadly had to add a new java class called gpsListener.java to eu/licentia/necessitas/industrius . Yo can read the readme file to find out why.

I would love to include those changes in the android-lighthouse project if you can direct me how. I am not very versed with git stuff.

I tested it on my Samsung Galaxy 5 (Android 2.1). I built the apk using the latest sdk and ndk. I downloaded android-lighthouse from git.

The normal jni.h that its included in the original qtmain_android.cpp is not compatible with the jni.h from Oracle. Hence the inclusion of Oracle's jni.h in the .pro.

With no further comments, enjoy the GPS from QT applications in Android!

Carlos.
PD
License information inside the readme
18th May 2011 at 12:57 (GMT+3) - I just posted a new tar.gz. It corrects a bug in the qtmain_android.cpp with prevented other applications to run because they don't have gpsListener.java.

raja26
16th November 2011, 14:45
Hello, thank for such a great & useful post:). Please use this link to contrubute to necessitas. BogDan is a member of Qt website. Surely some one will notify him about your contributions.
Thank you!

http://labs.qt.nokia.com/2011/02/28/necessitas/

tripo
20th March 2013, 09:42
thank you for the post :D

Kloohtroosht
19th September 2013, 00:10
This thread is little bit old, but i am facing similar problem.

I am trying to load jar library which is described here http://www.ftdichip.com/Support/Documents/AppNotes/AN_233_Java_D2xx_for_Android_API_User_Manual.pdf

I am using Qt5.1.1

This is sample of code and corresponding debug printout
...
jclass Intent = environment->FindClass("android/content/Intent");
qDebug() << "Intent" << Intent;
jclass Activity = environment->FindClass("android/app/Activity");
qDebug() << "Activity" << Activity;

jclass D2xxManager = environment->FindClass("com/ftdi/j2xx/D2xxManager");
qDebug() << "D2xxManager" << D2xxManager;
jclass FtDeviceInfoListNode = environment->FindClass("com/ftdi/j2xx/D2xxManager$FtDeviceInfoListNode");
qDebug() << "FtDeviceInfoListNode" << FtDeviceInfoListNode;
e = virtualMachine->DetachCurrentThread();
...

D/Qt (17677): ../androjqt/main.cpp:53 (int main(int, char**)): Intent 0x1d200011
D/Qt (17677): ../androjqt/main.cpp:55 (int main(int, char**)): Activity 0x1d200015
D/Qt (17677): ../androjqt/main.cpp:58 (int main(int, char**)): D2xxManager 0x0
D/Qt (17677): ../androjqt/main.cpp:60 (int main(int, char**)): FtDeviceInfoListNode 0x0
E/AndroidRuntime(17677): FATAL EXCEPTION: Thread-398
E/AndroidRuntime(17677): java.lang.NoClassDefFoundError: com/ftdi/j2xx/D2xxManager$FtDeviceInfoListNode
E/AndroidRuntime(17677): at dalvik.system.NativeStart.run(Native Method)
E/AndroidRuntime(17677): Caused by: java.lang.NoClassDefFoundError: com/ftdi/j2xx/D2xxManager
E/AndroidRuntime(17677): ... 1 more
E/AndroidRuntime(17677): Caused by: java.lang.ClassNotFoundException: com.ftdi.j2xx.D2xxManager
E/AndroidRuntime(17677): at dalvik.system.BaseDexClassLoader.findClass(BaseDex ClassLoader.java:61)

Here i see that finding classes in general is working, but my important library can't be found.
I have the two jar files in project/android/libs

Is nowadays still necessary to patch the qtmain_android.cpp ?
I haven't built qt from sources, it is from official binary distribution.

Am i doing something wrong?
Where is some documentation about loading third party jar libraries?

Thank you for any help

hipper
26th October 2013, 12:04
I have bookmarked this and will return soon more about it thank you.