'How to mock location without enabling setting

I am looking for a way to be able to mock location without needing to use ACCESS_MOCK_LOCATION. I know that I need to have root, move app to the system. But when "allow mock location" setting is disabled, the app just crashes even when it's in system partition.

I'd be glad for tips for Lilipop and Marshmallow (as far as I learned, they work differently...)



Solution 1:[1]

I think you want to mock location but prevent other apps (like Pokemon GO) detect "Allow mock location" is on. This is different between Marshmallow and before. - Before Marshmallow: please read here Use mock location without setting it in settings

  • Marshmallow: there is no "Allow mock location" option, you have to "Select mock location app". Other app cannot detect that you are mocking location. I have tested and can fake GPS to play Pokemon GO :)

Solution 2:[2]

You Can't set mock location without disabling the "ACCESS MOCK LOCATION" option in developer option, because this mode is used to test or debug the applications even google don't recommend to use mock location in app which is going to be release.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Community
Solution 2 Nirmal prajapat