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. Can not using the QAccelerometer in the android service
QtWS25 Last Chance

Can not using the QAccelerometer in the android service

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
1 Posts 1 Posters 188 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.
  • M Offline
    M Offline
    mr_roman
    wrote on last edited by
    #1

    Good evening. Sorry for my bad english :-(
    For several days i cannot solve the problem with start QAccelerometer in the android background service.

    I am developing the android service as separate .so file.
    In the service i write the following code:
    in .h file:

        private: 
            QAccelerometer *m_sensor;
    

    in .cpp file (in the constructor class):

        GSensorClass::GSensorClass(QObject *parent) : QObject(parent)
        {
            m_sensor = new QAccelerometer(this);
            connect(m_sensor, SIGNAL(readingChanged()),
                        this, SLOT(onReadingChanged()));
            m_sensor->setAlwaysOn(true); 
            m_sensor->start();
        }
    

    Unfortunately, the method start returns false(( If i call m_sensor->error(), it returns 0 (zero).

    In the service and main application .pro file i added Qt += sensors.
    In AndroidManifest.xml of the main application i added:

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

    If this code run under android GUI application, it works fine and i can access to x,y and z coordinates, but if this code run in the android service, then m_sensors->start(); returns false.

    Maybe I'm doing something wrong? I really hope, that this problem can be solved, using Qt.
    Please, help me.
    Thanks!

    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