Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pick an app to allow mock locations programmatically on Marshmallow?

Prior to Marshmallow "Allow mock locations" option could be changed programmatically(requires root)

Settings.Secure.putInt(getContentResolver(),Settings.Secure.ALLOW_MOCK_LOCATION, 1);

But now this option is app specific, means you have to pick the mocker app in developer options.

Is there a way to change this settings (inserting my app to allowed list) programmatically ?

like image 952
blackkara Avatar asked Aug 14 '16 12:08

blackkara


People also ask

How do you fake your location programmatically and avoid being tracked by companies?

“Mock Location” is a hidden developer setting in the Android operating system that allows a device owner to set any GPS location for testing purposes. Despite the fact that this is a developer setting, anyone can use it just by clicking a couple of buttons in device settings.

How do you use mock location without developer options?

Step 1: Download the Fake GPS Location app from the Google Play Store on your Android phone. Use the search bar, and it will pop up amongst the search results. Step 2: After installation, select this app as your mock location app on your phone by exploring your device settings.

Can an app detect mock location?

App checks alone cannot detect fake GPS locations entirely. The app knows what it's being told by the operating system, and Android, as an open-source OS makes it easier for external exploits to be introduced. Adding app certificate integrity checks is highly recommended.


1 Answers

No there is no way to give access to set the default mock location app. The most you can do is display a notification to user upon opening the app for the first time, giving them instructions on how this is done though the settings.

Note that for the user to do this, there is no need for root access, but rather developer access. This allows you to set the default mock location app.

Even the best mock location apps out in the market don't have this implemented by default. Hope this helps :)

--EDIT--

However, thre is a way to make this easier for the user to access. You can point the user to the actual screen where the mock-location app is set using the code below:

startActivity(new Intent(android.provider.Settings.ACTION_APPLICATION_DEVELOPMENT_SETTINGS));

This points the user to the screen where the mock-location app is set.

like image 85
Michele La Ferla Avatar answered Oct 28 '22 16:10

Michele La Ferla