I made an android application. I run application on laptop and located me at one place(in a wrong town about 250 km). When run application on my desktop with another api key, located me on the same wrong city. Can anyone tell me where is the problem? Thank you!
Share
In my experience, Android won’t acquire a location just because your Wi-Fi will inherit that to the Emulator.
You need to follow some steps:
Be sure to have the following permissions in your Android Manifest:
android.permission.INTERNET
android.permission.ACCESS_NETWORK_STATE
android.permission.ACCESS_COARSE_LOCATION
android.permission.ACCESS_FINE_LOCATION
android.permission.ACCESS_LOCATION_EXTRA_COMMANDS
android.permission.ACCESS_MOCK_LOCATION
android.permission.CHANGE_WIFI_STATE
android.permission.ACCESS_WIFI_STATE
Be sure to have the maps library in your Application tag:
Be sure to have a valid Maps API Key in your MapView in your /layout/map.xml file.
Because you are not running your App on an actual device, the only way to send different locations to your App is to push a MOCK LOCATION. To do so, simply Launch your App in the Emulator, go to the DDMS perspective in Eclipse IDE, and look for the options on the left (reset the DDMS perspective if you can’t find them). It should look like this:
Select the Emulator Name under the “Devices” Tab, then you can send Latitude and Longitude coordinates using the “Location Controls”.
When you are done developing and testing, be sure to remove the ACCESS_MOCK_LOCATION permission and to test the location detection on an actual phone or tablet with either GPS, aGPS chip or Cellular/Wifi Network.