I'm just wondering if it's possible to get an approximate location when the Location services on the phone is turned off.
For example, when I turn off my Location and open Google Maps, it shows my location in about a 2km radius. Then I can set start and end points for navigation.
In my own app, how can I do something similar? i.e. show their locality rather than just a map of India
Related
My question is can you get location coordinates latitude and longitude using WIFI or any other source when location is off or disabled. Basically I want to get current location when the GPS is not enabled
If location permission isn't granted or location settings are off, no. That's on purpose- the user doesn't want to give you their location, respect that. Now if it's just GPS but not location that's off you can use coarse location. That uses wifi only, is less accurate, but can be used with less battery drain than GPS.
I added a test provider using LocationManager.GPS_PROVIDER as provider name like described here
https://mobiarch.wordpress.com/2012/07/17/testing-with-mock-location-data-in-android/
In Google Maps app, I see location jumping between mocked location and real location, and then back to mocked location.
Why is jumping to real location and how can I stop it?
Maybe I misunderstand how to use mock locations. I haven't found any official documentation available.
You most likely have your location settings configured in a way that your phone (and apps) can use both the location from the GPS sensor and the location from the cells and wi-fi. Since the coming of the Fused Location Provider, the way the system fetches your location got a bit murkier.
When you mock the position you are only able to mock the GPS sensor readings (this is also true for when you mock the position through the simulator settings).
So when the system feeds Google Maps with a position from the GPS sensor it gives it the fake one, and when it provides the position from other sensors it will be the real one.
To test that I'm correct, you can switch location settings to "Device only" and you should only get the fake positions.
Unfortunately there's no way to mock the other sensors readings.
Turn off Wi-Fi scanning / Bluetooth scanning in the Location Settings to stop jumping to preserve mock location.
I created an application using Android GPS. This application shows user's current location name, latitude and longitude, GPS accuracy in Android mobile. I have tested this application in my android device. It was run in my mobile perfectly. But I can not get location name, latitude, longitude and accuracy when I was in Home or building. How do I create Toast text when I am not getting GPS coverage?
Thanks.
GPS works by connecting to four or more satellites and then triangulating your location by measuring the time it takes for the signal from various satellites to reach you, in a nutshell.
Due to this, you must have a clear view of the sky (sometimes even clouds can interfere), and GPS is unreliable and usually not working inside buildings and in underground locations.
Try using a different form of location tracking like the cell network for tracking the users inside buildings.
I have got two location listeners in my app, GPS and Network. They work fine except sometimes while traveling, the location name (returned from Geocoding API) shows very incorrect location for a small period of time (like a continent away).
Is there a way we can validate that the returned location (from location API and Geocoding API) is valid and only then show it to the user?
I tend to show the user the reported accuracy so they know within how many meters the reported position is. And then I only attempt to geocode an address if the accuracy is within a certain limit.
When you get your Location object, just call getAccuracy() on it to check.
I have a mapview where I want to track the user's current location. GPS as well as 'use wireless networks' is activated in my phone settings.
Nevertheless, since I'm indoor I don't get a GPS fix, therefore the location is determined via network; wifi spot is available.
I have the Google Maps app running as well as my application running.
Strangely, the current location differes between Google Maps and my application, where the Google Maps is very accurate while in my app the location is somehow off a few 100 meters.
In my application I basically do the following (for debugging purposes now):
1) initially place one marker on the map: geopoint retrieved via locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
2) initially place another marker on the map: geopoint retrieved via locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
This will put the last known locations of both providers onto the map (eventually last known from outside my app).
3) then for the regular updates (since I don't get a GPS fix anyway indoor here), I do:
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, baseLocationListener);
You can see for the frequency and distance I pass the 0 param in both cases.
In the app manifest, the following permissions are granted:
android.permission.ACCESS_COARSE_LOCATION
android.permission.ACCESS_FINE_LOCATION
android.permission.ACCESS_MOCK_LOCATION
Actually my baseLocationListener does get called, which I see in the log, but the updated location is somehow the same as the last known current position (of LocationManager.NETWORK_PROVIDER), same lat/lng.
I thought maybe I overlooked something or missed a parameter or setting, or my code has a bug. Therefore I installed some other (3 in total) LBS apps from the Android market that also show the current user's location. The current locations displayed in those apps are equals to the one in my application - and they're all some 100 meters off - but at least all the same.
See the screenshot here:
screenshot http://img33.imageshack.us/img33/8679/mapproblem.png
http://img33.imageshack.us/img33/8679/mapproblem.png
Now I am wondering:
1) as I understand, getLastKnowLocation is system-wide and not app-wide, why are there differences between the location in Google maps and all the other apps?
2) does Google Maps not update the lastKnownLocation of a provider?
3) does Google Maps use a different custom location provider (i.e. due to licensing reasons) other than GPS_PROVIDER or NETWORK_PROVIDER as they are in the SDK?
4) how do achieve the same accurate result with the NETWORK_PROVIDER like Google Maps does?
I think I found an answer, although not a solution. It seems that the problem is in the data quality of the different map provider that are used for Google Maps and MapView in SDK, which differ.
The map tiles coordinates don't seem to be very accurate, just like in the public google maps web api / tiles.
See this screenshot for an example, where I pinned the same geo point.
screenshot http://img339.imageshack.us/img339/2793/gmaps2.png
http://img339.imageshack.us/i/gmaps2.png/
The map using the public map api is off a few hundred meters.
Seems that we just have to live with it ?! :(
I know your post is one-year old, but the answer I think is that: Google map data in China is offset or distorted. I notice that you are in South China. The China government requires that for some security reasons. Here is the Google search results.
The transformation algorithm is unknown. Probably you can Google it, and wish you good luck.
The Map and Satellite images in Google Maps is off by a couple of meters, but I don't think it should be off that much. This seems to be a couple hundred meters.
Depending on how you acquired your position will dictate what position you get. From what I understand, these are the three levels of acquisition.
GPS
Network
WIFI
GPS and Network are determined by triangulation. GPS being the most accurate.
WIFI is done using a "whois", an address is acquired and then geocoded, being completely inaccurate at times.
Some phones say they are GPS, but they are most likely Pseudo-GPS like the iPhone 1.