Can not using the QAccelerometer in the android service
-
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!