Check if 'Allow dummy locations' is enabled

5

I have an application that requires the "Allow dummy locations" option of the standard Gallery enabled application to work. How can I check if it is enabled? How can I send the user to this item if my case is disabled? This option is in the Programmer menu, it is a hidden menu ... How to activate this menu and send the person up to the?

    
asked by anonymous 11.03.2015 / 19:39

2 answers

7

Resolved ...

To verify that the option is enabled:

private boolean isMockSettingsON() {
        return !Settings.Secure.getString(getContentResolver(),
                Settings.Secure.ALLOW_MOCK_LOCATION).equals("0");
}

To send the user to the dev menu:

Intent intent = new Intent(Settings.ACTION_APPLICATION_DEVELOPMENT_SETTINGS);
startActivity(intent);
    
12.03.2015 / 00:41
1

Complementing the response, the object Location has an information property if it was generated by mock, isFromMockProvider .

This is available from API 18.

Example:

if(!location.isFromMockProvider()){
 // Esta localização não foi gerada por um simulador
}
    
01.11.2016 / 21:12