Avoid removing the Testprovider from Mock Location

Asked

Viewed 228 times

5

I am trying to mock location for use in another application, but this application is removing my Testprovider, making it not possible to mock the location.

How can I avoid this other app from removing my Testprovider?

The code that the other application is running to avoid mocking is:

private void BuscarLocalizacaoAtual(String provider, LocationListener locationListener) {
    try {
        this.locationManager.removeTestProvider(provider);
    } catch (Exception e) {
    }
    this.locationManager.requestLocationUpdates(provider, time, 0.0f, locationListener);
}

*I would initially like to get around this problem through an apk. I know I could do this by editing the operating system.

100-dollar bill for anyone who helps me dribble this thing.

1 answer

1

Translated answer from Soen:

It seems the only way to do it is to use a simulated location provider.

You need to enable dummy locations in the development panel and your add settings to your manifest:

<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />

Now you can go in your code and create your own fake location provider and set the provider’s location.

Here a nice spot to pick up some more details!

  • In the example you reported it uses lm.addTestProvider, the app code removes the test Provider by overriding the mock Location.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.