I decompiled com.lexa.fakegps , which you talked about in the question, and what it does is this:
private int setMockLocationSettings() { int value = 1; try { value = Settings.Secure.getInt(getContentResolver(), Settings.Secure.ALLOW_MOCK_LOCATION); Settings.Secure.putInt(getContentResolver(), Settings.Secure.ALLOW_MOCK_LOCATION, 1); } catch (Exception e) { e.printStackTrace(); } return value; } private void restoreMockLocationSettings(int restore_value) { try { Settings.Secure.putInt(getContentResolver(), Settings.Secure.ALLOW_MOCK_LOCATION, restore_value); } catch (Exception e) { e.printStackTrace(); } } int value = setMockLocationSettings();
Since the execution time of this code is very short, other applications are unlikely to detect a change to ALLOW_MOCK_LOCATION.
Also you need
1. requires root access to your device
2. Move the application to /system/app or /system/priv-app
I tried it in my project and it works great.
source share