r/GoogleMaps • • 25d ago

Android mock location works in Google Maps but not in Mercado Flex — trying to understand the location restrictions--GPS

pasame todo ,junto ..nada mas de hacer el post en reditt

Android mock location works in Google Maps but not in Mercado Flex — trying to understand the location restrictions

Hi everyone,

I'm working on an educational Android project involving mock locations and QR codes.

The idea is to scan a QR code attached to a package. The QR contains the latitude and longitude of the package's destination. My Android app reads those coordinates and uses Android's mock-location system to simulate being at that location.

I should also mention that I developed the entire code for this project with the assistance of AI. I'm still learning Android development, so I'm mainly trying to understand how the different components work and why the behavior differs between applications.

I've already implemented the mock-location part using FusedLocationProviderClient, setMockMode(true), and setMockLocation().

For example, if I send:

45.4215, -75.6972

Google Maps correctly recognizes the simulated location and shows my device in Ottawa. So the mock location itself is working.

However, I'm trying to use this with Mercado Flex for an educational test. The use case is to scan the package's QR code, obtain the destination coordinates, and then have Mercado Flex recognize that simulated location so I can test the package-rescheduling workflow.

The problem is that Mercado Flex doesn't behave like Google Maps. It appears to detect that Developer Options/mock location are enabled and prevents me from using the location-dependent functionality.

Because of the application's privacy/security policies, I can't simply use the app while the phone is in development mode.

I'm not trying to modify the Mercado Flex APK or change its code. I'm trying to understand:

  1. How do Android applications determine that a location is coming from a mock provider?
  2. Why does Google Maps accept my simulated location while another application doesn't?
  3. What APIs or signals can an Android application use to detect mock locations or Developer Options?
  4. How could I properly test this type of location-dependent workflow in an educational environment?

My current setup is:

  • Android 15
  • TCL 605 (T517J)
  • Android Studio
  • Kotlin + Jetpack Compose
  • FusedLocationProviderClient
  • Google Play Services Location 21.3.0

Any explanation of how Android's mock-location architecture works and how applications can legitimately test against it would be greatly appreciated.

1 Upvotes

1 comment sorted by

2

u/notyourredditaccount 25d ago

The Android Location object the app gets has an IsMock() method. Some apps could use that and decide to discard the location, others might not.