Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set the android 6.0 mock location app from adb

Tags:

android

I would like to set the "mock location app" without any user intervention so I can partially automate some tests on Android 6.0.

geo fix is not appropriate in my situation.

Is it possible?

like image 907
Jonathan Barber Avatar asked Nov 04 '16 01:11

Jonathan Barber


People also ask

How do I set mock locations on Android?

Go to your “Settings”, “Systems”, “About Device” and tap multiple times on “Build number” and activate the Developer Mode. A new “Developer Options” menu will be available under “Settings” / “Systems” In the “Developer Options” menu, scroll down to “Debugging” and activate the “Allow mock locations”.

How do I turn on mock mock location on Android?

Open the 'Developer Options' menu and scroll to the bottom until you find 'Debugging'. Activate Mock Location by going to the 'Allow Mock Locations' option.

How do I select an app for a mock location?

After you download the app, go to Settings > Developer options and tap on Mock location app. Tap on it and it'll show all the available mock location apps installed on your device. Choose one and you're good to go. You can use the apps to select a location of your choice.


1 Answers

For Android 6.0+:

Allowing app for mock locaiton

adb shell appops set <PACKAGE> android:mock_location allow

Removing app for mock location

adb shell appops set <PACKAGE> android:mock_location deny

Checking if app is set for mock location

adb shell appops get <PACKAGE> android:mock_location
like image 134
Pablo Baxter Avatar answered Sep 19 '22 03:09

Pablo Baxter