[Development] Does QGeoPositionInfoSource work from an Android service?

Denis Shienkov denis.shienkov at gmail.com
Thu Oct 25 11:30:22 CEST 2018


Alex,

I have created a bug: https://bugreports.qt.io/browse/QTBUG-71396
Please look on...

Denis

чт, 25 окт. 2018 г. в 9:42, Alex Blasche <alexander.blasche at qt.io>:

> Hi Denis,
>
> At least in the past it worked as I remember having tested the use case.
> Do you have a backtrace?
>
> And yes, Ryan's comment is correct in that you are missing essential error
> checking in your code.
>
> --
> Alex
>
> ________________________________________
> From: Denis Shienkov <denis.shienkov at gmail.com>
> Sent: Wednesday, 24 October 2018 6:31:59 PM
> To: development at qt-project.org; Alex Blasche; BogDan Vatra
> Subject: Does QGeoPositionInfoSource work from an Android service?
>
> Hi all,
>
> I tried to make it work from the Android service:
>
>
> #include <QAndroidService>
>
> #include <QGeoPositionInfoSource>
>
> #include <QLoggingCategory>
>
> #include <QTimer>
>
>
> Q_LOGGING_CATEGORY(APP, "bug.svc")
>
>
> int main(int argc, char *argv[])
>
> {
>
>     QAndroidService::setAttribute(Qt::AA_EnableHighDpiScaling);
>
>     QAndroidService app(argc, argv);
>
>
>     qCDebug(APP) << "I'm service";
>
>
>     const auto t = new QTimer(qApp);
>
>     QCoreApplication::connect(t, &QTimer::timeout, []() {
>
>         static int counter = 0;
>
>         qCWarning(APP) << "CNT:" << counter;
>
>         ++counter;
>
>     });
>
>     t->start(1000);
>
>
>     const auto ps = QGeoPositionInfoSource::createDefaultSource(qApp);
>
>     QCoreApplication::connect(ps, &QGeoPositionInfoSource::positionUpdated,
>
>                               [=](const QGeoPositionInfo &update) {
>
>         const auto coord = update.coordinate();
>
>         qCDebug(APP) << "CRD:" << coord;
>
>     });
>
>     ps->setUpdateInterval(3000);
>
>     ps->startUpdates();
>
>
>     return app.exec();
>
> }
>
> but a service, seems, crashed at all (at least I did not see any debugging
> log from the logcat).
>
> But if I try to cemment out all code, related to the locations, and keep a
> code with the timer,
> then I see the counters output.
>
> I tried it on Android x86 && Qt 5.11.2 && Android API 21.
>
> E.g. from here:
> https://stackoverflow.com/questions/13345002/locationmanager-in-service
> I see that it is possible to wotk with Android's LocationManager from the
> service... BUT,
> it does not work with QGeoPositionInfoSource!
>
> BR,
> Denis
>
>
>
>
> _______________________________________________
> Development mailing list
> Development at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/development
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20181025/ead7856d/attachment.html>


More information about the Development mailing list