0

I am developing an Android app purely on geofence.

Concept: My basic concept on geofence is user can play games for particular geo location.

Problem: Everything is working fine but I downloaded the FakeGPS application from here. I was at home and I setup my desired location from where I can play game. My application has detected that geo location and I could play that game from my home. Actually it was supposed to play that game only for geo location.

Solution: I have checked that location is coming from MockProvider or not on GeofenceIntentService class by given code.

boolean isMockLcoation = geofencingEvent.getTriggeringLocation().isFromMockProvider();

But its not a reliable solution. I am not getting every time accurate result.

I have checked LocationAssistance service but anyway it couldn't help me for geofence.

Goal: I want to either disable mock location for my application or distinguish the location is true or mock.

Hiren Patel
  • 52,124
  • 21
  • 173
  • 151

1 Answers1

0

You may just want to check if mock location setting is enabled. Here is a SO answer just for that, or you can just use the code below, which was from that same answer.

https://stackoverflow.com/a/16776891/5318240

public static boolean isMockSettingsON(Context context) {
    // returns true if mock location enabled, false if not enabled.
    if (Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ALLOW_MOCK_LOCATION).equals("0"))
        return false;
    else
        return true;
}
Community
  • 1
  • 1
Pablo Baxter
  • 2,144
  • 1
  • 17
  • 36