Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Getting GPS coordinate in Qt 5 android application
Forum Update on Monday, May 27th 2025

Getting GPS coordinate in Qt 5 android application

Scheduled Pinned Locked Moved Mobile and Embedded
16 Posts 7 Posters 16.5k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    darkelfe
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • A Offline
      A Offline
      amccarthy
      wrote on last edited by
      #2

      There is no Android backend for Qt Location.

      1 Reply Last reply
      0
      • D Offline
        D Offline
        darkelfe
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        • A Offline
          A Offline
          AlterX
          wrote on last edited by
          #4

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

          Really? why?!
          Will it be added?

          Qt Ambassador
          Real-time cooperative teams: http://www.softairrealfight.net
          Free Real-time network platform sdk: https://github.com/AlterX76/Solomon

          https://codereview.qt-project.org/...

          1 Reply Last reply
          0
          • A Offline
            A Offline
            amccarthy
            wrote on last edited by
            #5

            [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.

            1 Reply Last reply
            0
            • A Offline
              A Offline
              AlterX
              wrote on last edited by
              #6

              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?!

              Qt Ambassador
              Real-time cooperative teams: http://www.softairrealfight.net
              Free Real-time network platform sdk: https://github.com/AlterX76/Solomon

              https://codereview.qt-project.org/...

              1 Reply Last reply
              0
              • A Offline
                A Offline
                amccarthy
                wrote on last edited by
                #7

                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.

                1 Reply Last reply
                0
                • A Offline
                  A Offline
                  AlterX
                  wrote on last edited by
                  #8

                  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).

                  Qt Ambassador
                  Real-time cooperative teams: http://www.softairrealfight.net
                  Free Real-time network platform sdk: https://github.com/AlterX76/Solomon

                  https://codereview.qt-project.org/...

                  1 Reply Last reply
                  0
                  • Gojir4G Offline
                    Gojir4G Offline
                    Gojir4
                    wrote on last edited by
                    #9

                    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

                    1 Reply Last reply
                    0
                    • A Offline
                      A Offline
                      AlterX
                      wrote on last edited by
                      #10

                      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

                      Qt Ambassador
                      Real-time cooperative teams: http://www.softairrealfight.net
                      Free Real-time network platform sdk: https://github.com/AlterX76/Solomon

                      https://codereview.qt-project.org/...

                      1 Reply Last reply
                      0
                      • J Offline
                        J Offline
                        jeffreyholmes
                        wrote on last edited by
                        #11

                        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: () *

                        1 Reply Last reply
                        0
                        • J Offline
                          J Offline
                          jeffreyholmes
                          wrote on last edited by
                          #12

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

                          1 Reply Last reply
                          0
                          • J Offline
                            J Offline
                            jeffreyholmes
                            wrote on last edited by
                            #13

                            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

                            1 Reply Last reply
                            0
                            • S Offline
                              S Offline
                              sonyericsson0819
                              wrote on last edited by
                              #14

                              [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

                              1 Reply Last reply
                              0
                              • X Offline
                                X Offline
                                xsjqqq123
                                wrote on last edited by
                                #15

                                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 ^_^

                                1 Reply Last reply
                                0
                                • S Offline
                                  S Offline
                                  sonyericsson0819
                                  wrote on last edited by
                                  #16

                                  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]

                                  1 Reply Last reply
                                  0

                                  • Login

                                  • Login or register to search.
                                  • First post
                                    Last post
                                  0
                                  • Categories
                                  • Recent
                                  • Tags
                                  • Popular
                                  • Users
                                  • Groups
                                  • Search
                                  • Get Qt Extensions
                                  • Unsolved