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. Compass sensor on Android
Forum Updated to NodeBB v4.3 + New Features

Compass sensor on Android

Scheduled Pinned Locked Moved Solved Mobile and Embedded
2 Posts 1 Posters 317 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.
  • R Offline
    R Offline
    RogueWarrior
    wrote on 23 Feb 2024, 02:26 last edited by
    #1

    I'm using Qt 6.5 and I'm trying to make use of the compass sensor on an Android device.
    The problem is that listing all the available sensors, the compass is not among them.

    This code is from the Qt Sensors documentation:

    QList<QSensor*> mySensorList;
    for (const QByteArray &type : QSensor::sensorTypes()) {
        qDebug() << "Found a sensor type:" << type;
        for (const QByteArray &identifier : QSensor::sensorsForType(type)) {
            qDebug() << "    " << "Found a sensor of that type:" << identifier;
            QSensor* sensor = new QSensor(type, this);
            sensor->setIdentifier(identifier);
            mySensorList.append(sensor);
        }
    }
    

    Here's the output:

    Found a sensor type: "QOrientationSensor"
    Found a sensor of that type: "generic.orientation"
    Found a sensor type: "QPressureSensor"
    Found a sensor of that type: "6"
    Found a sensor type: "QProximitySensor"
    Found a sensor of that type: "8"
    Found a sensor type: "QAccelerometer"
    Found a sensor of that type: "1"
    Found a sensor of that type: "dummy.accelerometer"
    Found a sensor type: "QLightSensor"
    Found a sensor of that type: "5"
    Found a sensor type: "QAmbientLightSensor"
    Found a sensor of that type: "dummy.lightsensor"
    Found a sensor of that type: "generic.als"
    Found a sensor type: "QTiltSensor"
    Found a sensor of that type: "generic.tilt"

    I have in my AndroidManifest.xml:

    <uses-feature android:name="android.hardware.sensor.accelerometer"/>
    <uses-feature android:name="android.hardware.sensor.compass"/>
    

    Anyone have any idea why I can't get a compass sensor?

    1 Reply Last reply
    0
    • R Offline
      R Offline
      RogueWarrior
      wrote on 23 Feb 2024, 16:23 last edited by
      #2

      Never mind. Stupid Samsung AO3s doesn't have a compass.

      1 Reply Last reply
      0
      • R RogueWarrior has marked this topic as solved on 23 Feb 2024, 16:23

      1/2

      23 Feb 2024, 02:26

      • Login

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