Getting GPS coordinate in Qt 5 android application



  • Hello,

    [Note: Sorry if my English is not perfect, i'm French]

    I try to create a mobile application (for android at this moment) in order to just display current GPS coordinate.
    After some research, i found the Qt Location module. It seems perfect for my application, so i decide to use it.

    So i create a little program to display GPS coordinates in console (using QDebug). The application perfectly compile and i deploy it on my android (Alcatel 995 One-Touch, android api 15).

    But, when the application runs, i can't get an instance with QGeoPositionInfoSource::createDefaultSource() but it returns 0. I also try to display all sources (using QGeoPositionInfoSource::availableSources()) but i get an empty QStringList.
    Yes, i check my GPS are turned on in my phone and i get the "android.permission.ACCESS_FINE_LOCATION" permission to my app.

    I also try my app on a simulator, but app doesn't start because simulator not provide OpenGL ES API.

    Have some people any idea why i don't have any sources for QGeoPositionInfoSource ?

    Thanks.



  • There is no Android backend for Qt Location.



  • Ok.

    So, anybody have any idea to get GPS coordinate in my app ? And, if possible, a solution that work for Android and iOS ?

    Thanks.



  • [quote author="amccarthy" date="1371620995"]There is no Android backend for Qt Location.[/quote]

    Really? why?!
    Will it be added?



  • [quote author="AlterX" date="1372088265"]Really?[/quote]

    Yes.

    [quote]why?![/quote]

    Qt Location has not been part of any official Qt 5 release, it works reasonable well on some platforms but not all.

    Development of Qt Location effectively stopped prior to the release of Qt 5.0. This was prior to the start of the Qt Android port. Qt Location is also not a classified as an essential module, meaning that it does not need to support all of the platforms that Qt supports.

    In respect to Qt Location Android is in the same position as most other platforms. GPS positioning is only supported on platforms that support geoclue and Nokia platforms. Excluding the Nokia platforms, I have only ever seen positioning working on Linux.

    [quote]Will it be added?[/quote]

    Qt is an open source project, anyone can contribute a backend for the favourite platform. That being Digia has started reevaluating whether development of Qt Location should restart. To following progress on Qt Location development look at "QTBUG-23412":https://bugreports.qt-project.org/browse/QTBUG-23412 and its sub-tasks.



  • I don't think QtLocation is not part of official Qt...I mean now Digia support ios and android in which location is an important part of mobile systems...if android and ios's Qt don't support location then it's useless to use Qt on those platform!
    I'am in process of converting my app softair to android and now I have to give up due to the lack of location?!



  • From a Qt 5 perspective Qt Location is an unrelease library. I outlined the reasons why it has not been released in my previous post. It takes time to port to new platforms and this work is only just being started now.

    If you look at the bug report I linked to you will see that the short term plan is to release Qt Location as part of Qt 5.2, for the platforms that Qt Location currently works on.

    A mid to long term goal is to add iOS and Android support. There is no target Qt 5 release specified, but it is probably safe to assume this is post Qt 5.2.

    Why do you need to give up porting your application. Qt does not prohibit you from using native APIs if a Qt API is not currently available.



  • I've planned to port my app "Softair":http://www.softairrealfight.net that use gps as important part of game.
    I've already started port of that on android using Qt 5.1 and it sounds very good...it almost works with just some changes, but I need gps to use that....
    I've seen the storyboard but, sincerily, I didn't catch why they didn't use necessitas QtLocation (ok that isn't so good, but it is a already done).



  • You could use JNI (Java Native Intrface) to access the GPS, or any other native Android features which are not supported by Qt directly. This is not simple but it seems it works (I haven't tested yet, but I have to, for NFC).
    See this link as an example : "QT in Android -- Example for accessing the GPS Service":http://www.qtcentre.org/threads/41698-QT-in-Android-Example-for-accessing-the-GPS-Service This is an example with Qt 4.x + Necessitas but I think you can easily adapt it for Qt 5

    You can also find good tutorials there "JNITurorial":https://code.google.com/p/awesomeguy/wiki/JNITutorial#Create_Android_Project
    or from Google of course.

    Hope this helps



  • Ok thank you,
    I had already seen this post, but I don't know, because I don't want to waste my time so much and then go back with official solution



  • 2014 Now and i see Qt 5.2.1 has QGeoPositionInfo and QGeoSatelliteInfo.. but checking sources on my Galaxy Note 2 i get no available sources ?

    Is this suppose to work yet on Android using Qt 5.2.1 deploying to Devices?

    D/Qt ( 5617): appmodel.cpp:77 (void AppModel::networkSessionOpened()): QGeoPositionInfoSource *Available Sources: () *
    D/Qt ( 5617): appmodel.cpp:78 (void AppModel::networkSessionOpened()): QGeoSatelliteInfoSource *Available Sources: () *



  • Sorry, please ignore my last post.. here is a topic about this
    "here":http://qt-project.org/forums/viewthread/35845



  • I think we can expect the functional QtPositioning Class working in Qt 5.3

    http://qt-project.org/wiki/New-Features-in-Qt-5.3



  • [quote author="jeffreyholmes" date="1393151238"]I think we can expect the functional QtPositioning Class working in Qt 5.3

    http://qt-project.org/wiki/New-Features-in-Qt-5.3[/quote]

    Thank you for your reminder of the new features of Qt5.3 , it's very helpful for me.I was also puzzled by QtPositioning, it doesn't work in My Android 4.4 and Windows 7.Sorry,I can't use English fluently,I just want to say thanks for you



  • I can't give my android app a icon,can you give me advice on how to set an icon for android?
    my english more poor than you ^_^



  • I use "Eclipse" for setting an icon.And you can also add "ANDROID_PACKAGE_SOURCE_DIR" in the *.pro file,then create a folder and put "AndroidManifest.xml",it also can help to set icon.You can see Example:"Qt Notifier" in Qt. (^.^)

    [quote author="xsjqqq123" date="1393515753"]I can't give my android app a icon,can you give me advice on how to set an icon for android?
    my english more poor than you ^_^[/quote]


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.