Android Mock locations

  • Hello,

    I am implementing an app that awards users with rewards based on their location, through GPS.

    The issue on Android is that users may use a mock location spoofer to get the rewards without moving.

    Is there a way in Qt to know that a location has been spoofed? when I print the name of the source on Android is... "android".

    There are/were several ways to do that on Android through the LocationManager, (I am fine with using JNI calls), however these have been deprecated in favor of a "mock location?" flag for each data point. However this would mean departing from Qt's Gps classes and using Java directly.

    Has anyone else tried to do something similar?

    Thank you.

  • Lifetime Qt Champion


    This stack overflow post might what you are looking (also take a look at the comments).It's only native API but you could write a small helper library to provide a Qt API for that.

    Hope it helps

  • @SGaist Thank you, I am actually already using this now, but it has its shortcomings (see Pokemon Go posts about how to cheat these methods :) ). I hoped there would be something more "Qt-native".

  • Lifetime Qt Champion

    Well, Qt is using whatever the platform provides and I don't think (I may be wrong though) that this is the kind of scenario that the devs behind the module would think of. Looks like even the android dev didn't thought about having this working only when developing an application.

  • qt doesn't have this funtionality u need to:

    1. check Settings.Secure.ALLOW_MOCK_LOCATION string on API Level < 23 (or 21 - don't remember)
    2. on API level >=23 u need to check isFromMockProvider on returned Location object

Log in to reply