android how to set a fake location to phone -


I'm trying to use fake location over the phone but it's showing exceptions,

My code is below, Location location = New location (MOCK_PROVIDER_NAME); Location.setLatitude (latitude); Location.setLongitude (longitude); Location.setTime (new date (.) GetTime ()); LocationManager.setTestProviderEnabled (MOCK_PROVIDER_NAME, true); LocationManager.setTestProviderLocation (MOCK_PROVIDER_NAME, Location); Toast. MakeBaseContext (), "Latitude:" + location. GETLITITUDE () + "Longitude:" + location. Gate lengtewood (toast). LNNGHHORT). Show (); I gave MOCK_PROVIDER_NAME = "GPS" but it is also not trying with "network" and "cheating", but it is not working.

Where I am going wrong, tell me anyone. Thank you

Here are two possible reasons for your problem:

A security exception:

If the ACCESS_MOCK_LOCATION permission is missing or the settings are not protected. ALLOW_MOCK_LOCATION is not enabled in the system setting

or the invalid agreement exception:

< P> If a provider with the given name already exists

I have received those quotation marks:

If it is not one of those exceptions Which you Received are, then we let the stack trace of the error as well as any problems with the stack trace show in your code.

I'm thinking that you have not explicitly announced permission and / or "Allow duplication location" is closed in the development setting

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -