I have an Android app that serves as a graphical interface for a small daemon (written in C ++) that should run on various mobile / embedded Linux devices. The daemon must collect GPS data and transmit it to several clients (Android phones, each with a graphical interface). The daemon should be able to work on one of those Android devices that is used as a graphical interface, but I have a lot of problems accessing GPS data from the C ++ daemon.
I considered two options:
1) The "stay home" method . I heard that gpsd exists for Android (for example, here is http://esr.ibiblio.org/?p=4886 ), but it seems elusive and / or does not exist on my Samsung Galaxy SII running on Cyanogenmod 10.1.3- i9100 (Android 4.2.2). My standalone toolchain built from NDK has nothing to do with gps at all, although sites like this one ( http://www.jayway.com/2010/01/25/boosting-android-performance-using-jni/ ) indicate that java uses JNI wrappers to use C code to talk to GPS anyway.
2) The jni method : GPS seems very easy in Android Java applications, so I started learning JNI (by the way, I'm pretty new to Android and Java). It is assumed that it will be able to interact with C code and Java code, right? I read this on this site ( http://journals.ecs.soton.ac.uk/java/tutorial/native1.1/implementing/index.html ) and this site ( http://journals.ecs.soton.ac .uk / java / tutorial / native1.1 / implementing / index.html ) and many others. But this is happening to me. I have not seen any C code using JNI in which there is a main() function. In addition, the JNI_CreateJavaVM() function is commented out in the jni.h header file of my NDK binding. In fact, I cannot figure out how to have a valid JNIEnv* in the first place. I came to the conclusion that JNI code is intended for use by Java applications that need C support, not C applications that need Java support. It is right?
And then I have a third thought, which I really dislike:
3) backup method . In cases where the C ++ daemon runs on an Android phone, maybe it can request the Android GUI for GPS data and then pass it on to other clients? I think they can communicate through a socket or something simple. This seems like a really ugly solution, because despite the apparent inefficiency, the daemon should be able to work independently of any GUI, but now it will depend on the graphical interface for GPS data.
So my real question is: did someone else come across this problem and find a suitable answer? Or maybe there is something that I do not understand something about aobut gpsd in Android or about JNI in Android?
Thanks for reading.
c ++ android jni gps
rexroni
source share