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. QT5 Android Positioning, not working without SIM card
Forum Updated to NodeBB v4.3 + New Features

QT5 Android Positioning, not working without SIM card

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
4 Posts 3 Posters 470 Views 1 Watching
  • 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.
  • M Offline
    M Offline
    MartinGU
    wrote on last edited by
    #1

    Using Positioning in Android, works great if the phone/tablet has a SIM card installed.
    Without a SIM card the slots never gets called!

    Is this a QT or pure Android problem?
    Is there any way around it?

    Without SIM card I do not get any error (not slots are called, QGeoPositionInfoSource::createDefaultSource() works), so I don't know how to tell the user why they cannot get the position!

    QT 5.15.2, (built on Linux Mint), NDK 21.3.6528147

    QGeoPositionInfoSource *gpsSrc;
       
    gpsSrc = QGeoPositionInfoSource::createDefaultSource(0);
    
     if (gpsSrc)
     {
    // Get here regardless of SIM card or not
     gpsSrc->setPreferredPositioningMethods(QGeoPositionInfoSource::AllPositioningMethods);
    
     connect(gpsSrc, SIGNAL(positionUpdated(QGeoPositionInfo)), this, SLOT(positionUpdated(QGeoPositionInfo)));
    
    connect(gpsSrc, SIGNAL(error(QGeoPositionInfoSource::Error positioningError)), this, SLOT(positionError(QGeoPositionInfoSource::Error positioningError)));
    
    connect(gpsSrc, SIGNAL(QGeoPositionInfoSource::updateTimeout()), this, SLOT(updateTimeout()));
    // Without SIM card none of the slots gets called
    }
    
    M 1 Reply Last reply
    0
    • M MartinGU

      Using Positioning in Android, works great if the phone/tablet has a SIM card installed.
      Without a SIM card the slots never gets called!

      Is this a QT or pure Android problem?
      Is there any way around it?

      Without SIM card I do not get any error (not slots are called, QGeoPositionInfoSource::createDefaultSource() works), so I don't know how to tell the user why they cannot get the position!

      QT 5.15.2, (built on Linux Mint), NDK 21.3.6528147

      QGeoPositionInfoSource *gpsSrc;
         
      gpsSrc = QGeoPositionInfoSource::createDefaultSource(0);
      
       if (gpsSrc)
       {
      // Get here regardless of SIM card or not
       gpsSrc->setPreferredPositioningMethods(QGeoPositionInfoSource::AllPositioningMethods);
      
       connect(gpsSrc, SIGNAL(positionUpdated(QGeoPositionInfo)), this, SLOT(positionUpdated(QGeoPositionInfo)));
      
      connect(gpsSrc, SIGNAL(error(QGeoPositionInfoSource::Error positioningError)), this, SLOT(positionError(QGeoPositionInfoSource::Error positioningError)));
      
      connect(gpsSrc, SIGNAL(QGeoPositionInfoSource::updateTimeout()), this, SLOT(updateTimeout()));
      // Without SIM card none of the slots gets called
      }
      
      M Offline
      M Offline
      MartinGU
      wrote on last edited by
      #2

      @MartinGU

      Additional information:

      When debugging on the phone without SIM card I get:

      W libtid_armeabi-v7a.so: QObject::connect: No such signal QGeoPositionInfoSourceAndroid::error(QGeoPositionInfoSource::Error positioningError) in ../mobile/dlg_main.cpp:87
      W libtid_armeabi-v7a.so: QObject::connect:  (receiver name: 'DLG_MAIN')
      W libtid_armeabi-v7a.so: QObject::connect: No such signal QGeoPositionInfoSourceAndroid::QGeoPositionInfoSource::updateTimeout() in ../mobile/dlg_main.cpp:90
      W libtid_armeabi-v7a.so: QObject::connect:  (receiver name: 'DLG_MAIN')
      D QtPositioning: Regular updates using GPS 50
      

      With SIM card (same phone):

      W libtid_armeabi-v7a.so: QObject::connect: No such signal QGeoPositionInfoSourceAndroid::error(QGeoPositionInfoSource::Error positioningError) in ../mobile/dlg_main.cpp:369
      W libtid_armeabi-v7a.so: QObject::connect:  (receiver name: 'DLG_MAIN')
      D QtPositioning: Regular updates using GPS 50
      
      1 Reply Last reply
      0
      • sierdzioS Offline
        sierdzioS Offline
        sierdzio
        Moderators
        wrote on last edited by
        #3

        Looks like your signal-slot connections are wrong. If only possible, use functor-based connections https://doc.qt.io/qt-5/signalsandslots-syntaxes.html it will fail to compile if you use wrong signal / slot functions.

        I don't know if it will help in finding location, but it sure will help in getting slots to work.

        (Z(:^

        1 Reply Last reply
        1
        • I Offline
          I Offline
          ivan.solovev
          wrote on last edited by
          #4

          Hi @MartinGU

          Not sure if you already solved your issue, or if it's still relevant for you.

          First of all, I do not think that you can use parameter names in signal/slot connection, like you do it for error signal.
          The correct way would be to do as follows:

          connect(gpsSrc, SIGNAL(positionUpdated(QGeoPositionInfo)), 
                  this, SLOT(positionUpdated(QGeoPositionInfo)));
          connect(gpsSrc, SIGNAL(error(QGeoPositionInfoSource::Error)), 
                  this, SLOT(positionError(QGeoPositionInfoSource::Error)));
          connect(gpsSrc, SIGNAL(updateTimeout()), this, SLOT(updateTimeout()));
          

          Hope this will allow you to catch the errors, if there are any.

          After setting preferred positioning methods you can also query them, as well as supported positioning methods, just to make sure that everything is set up correctly.
          To do so, call:

          gpsSrc->preferredPositioningMethods();
          gpsSrc->supportedPositioningMethods();
          

          Make sure that both outputs contain QGeoPositionInfoSource::SatellitePositioningMethods value.

          Last but not least, in your log I see

          D QtPositioning: Regular updates using GPS 50
          

          which indicates that Android at least tries to start positioning updates using GPS in both cases (with and without SIM card). If GPS sensor performs a cold boot, it might take quite some time to actually start getting GPS updates. It's possible that with the SIM card you get initial updates based on the rough position from the cell.

          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