I'm using Google Play Services to get the current location of the user. Basically I use the codes at http://www.androidhive.info/2015/02/android-location-api-using-google-play-services/ to get the location. So herein lies my problem:
1) I can get the current user location on my Xperia Mini (Running ICS) without any problem. If I didn't enable the GPS, the location that I'd receive (expectedly) isn't that accurate, but I will still get it. And if I enable the GPS, I would (again, expectedly) receive a much more accurate location.
2) But when I tried running my app on my Zenfone C (Running KitKat), if I didn't enable location, I would never get any location. getLastLocation and onLocationChanged will always return null. Only after I enable location, I'd get the location. But after I disable location and tried to getLastLocation again, it will again, return null.
The situation that occurs on my Zenfone C puzzles me, because from my understanding, even if we didn't enable location/GPS, we would still be able to get the current location from the mobile network or wifi triangulation, because that's what happening with my Xperia Mini, and I thought that should be the standard for all Android devices? Or is the enable location on/off on some Android devices have some other meaning? Perhaps on some device, when location is turned off, there's no way we can get the location. Can anyone here shed some light on this?
Thanks
There's no way for the device to get new locations once the location mode is set to off, but it's possible that the one device had a cached location from when the location mode was set to on.
Network location (Power saving mode on some Android versions) needs to be enabled to get a location from mobile data or WiFi. Note that if you use the toggle button, it enables/disables both network location and GPS (High Accuracy mode). You can use the sub-modes to enable only one location mode (Power Saving for Network only, or GPS only).
For more info, take a look at the screenshots in this answer.
Related
I have make an android application which help us to get GPS Location using A-gps in my android phone. I am getting latitude and longitude successfully in Metro Cities of my country, but when I am going to some forest area,GPS do not get location and for this I need to run GPRS of my phone,after running google map once in my phone ,GPS successfully gets latitude and longitude even if I closes my internet connection or remove sim card from my phone. But since I do not want to use google map, what should I do now and why it is happening?? Any help will be appreciable
It takes a long time (several minutes) to get the GPS location with high precision. However, if you enable network based location (e.g. cell tower, WiFi), it's way faster but with lower precision.
As a result, you should listen to all the providers with LocationManager, and figure out which provides the best location. Or, if your app targets Android 8 and above, you can use the Location APIs provided with Google Play Services, which hides the details as using LocationManager directly.
First make sure that it is not the fault of your phone or its operation system version.
Download a well working known GPS App, look if they get a GPS signal without internet.
Place it under very good cointions: free view to sky, outside dense city, at least an open place.
You should get a signal within one minute, maybe if the phone has a poor built-in GPS antenna, a bit more, wait some minutes.
If the well working foreign app still don't get GPS it's an Operating system bug.
If you get one, then it´s your fault, and it is worth for further investigation.
*first check your GPS working or not properly with **ANDROITS GPS TEST*.
if it finds and fixes satellite do not worry. as AGPS is fast , standlone GPS needs to have much more time to fix on its own especially in city as many radio waves disturbs GPS fixure.
better first fix with AGPS and then you can turn off data or internet, still it will work as it already had its location and satellites fixed.
with standlone GPS it takes huge time and battery.**
If your phone use GPS h/w to get the location information, it don't require any internet connection. It should be able to get the location fix using GPS without the help of internet. But it may take some time to get the location fix.
You can install the this free app from play-store to test the GPS of your phone : "TestYourGPS".
https://play.google.com/store/apps/details?id=com.eorsavik.testyourgps
I am finishing an Android application in which I am observing location changes from gps and network providers. My problems is that I have enable both providers properly and I am requesting location updates from each provider. (I am testing on actual phones not a simulator to clarify.) GPS works flawlessly the majority of the time unless I can not get a gps lock(This is expected). I have been racking my brain over why network location are returned null on some phones some of the time and only seem to begin receiving location updates for "network" after phone has been restarted (Not ideal). I have wifi enabled. All the correct permissions Internet,coarse and fine. Gps updates are working just fine. I have tried removing updates from the listener and then requesting again after a set time of receiving null. I have seen this on the S3, One X, galaxy nexus, and a Motorola Droid M. At first I thought it was a hardware issue. Seems like some of the posts out here are related to the same topic. I just want to see if anybody out there has come across a fix or a work around?
Is there a recognized problem with geolocation via the default browser in Android 2.3.4 Gingerbread?
On an HTC G2 android 2.3.4, the default browser does not appear to use the GPS satellites to determine location. As a result, the location the browser sends to the app is off by a mile or so. Yes, the GPS and wi-fi were both on in the phone. We turned wi-fi off and got the same (bad) result.
Is there some voodoo that can be done to get the default browser in 2.3.4 to do proper geolocation?
On an iPhone 3s geolocation with the very same browser app works perfectly. The following link starts the Gmap4 app (I am the developer) and shows your location on the Google 'Hybrid" map:
http://www.mappingsupport.com/p/gmap4.php?mylocation=on
I believe this is not a browser problem, but a phone specific issue. If you are getting a position off by a mile, for sure the position has been acquired from wifi.
When you start the map, it tries to get the LastKnownLocation, and if it's to old it reverts to wifi position. Now, if you turn wifi off, the position acquiried using wi-fi will remain available as a recent LastKnownLocation and will be used to position the map again.
Until you get a better position from GPS this one will be used.
At least some phones discard the LastKnownLocation when you restart them. You can try it, with wifi off, to see what happens.
Regards.
I have an existing well-tested app that utilizes the GPS_PROVIDER and NETWORK_PROVIDER with the same LocationListener.
LocationManager reports gps, network, and passive location providers are available and enabled.
I have recently upgraded my Galaxy Nexus to 4.1.1 and now the NETWORK_PROVIDER does not deliver any location changes. Testing with an Galaxy S III running 4.0.4 works as I am accustomed to, with network location updates coming through, even if WiFi is turned off. When WiFi is turned off, I get the cell tower position.
Talking with colleagues here, I can't rule out some kind of coincidental hardware failure or some sort of default setting change that I haven't found. I've double checked throughout the settings and it appears that everything is properly set.
WiFi is on, Cell network is on, GPS is on, network services are all enabled. I have no GPS signal at my desk, so it's easy to notice when the network location fails to provide a result.
Anyone else running into similar issues with Verizon Galaxy Nexus + 4.1.1, or 4.1.1 and any phone?
As an additional wrinkle, Google Maps is finding my location, but my PASSIVE_PROVIDER is not generating a location either.
The behavior of Android has not changed with regard to the NETWORK_PROVIDER.
I don't know what went wrong or why, but I removed/replaced the battery and SIM card on my Galaxy Nexus and the network provider seems to be providing the correct results.
The lesson for me? Do not assume you will ever get a location reported to your listener, even if you are certain that the network provider is available, enabled and connected.
In my case, I'll need to add another check to make sure my LocationListener does not keep running if I do not get any locations reported.
I have read someone's supposition about this problem.
It is "In some devices if there is no update after request then a network provider do not give a callback".
Consider that possibility.
In my case, I use a getLastKnownLocation() before starting a current location tracking.
Try ctrl+f getLastKnownLocation in this article.
Hey I am beginning to look into making an android app. Trying to use the phonegap right now.
I was just wondering about the geolocation service. It seems the address is always a few block off of my actual location. Even if I have it set to enable hight accuracy. How come GPS people have in their cars know down to the location on the block they are on. Is there a way to get an accuracy like this with android? Or is it easier to get better data when moving?
Do you have GPS enabled? Android phones can get location based on network (GPRS, EDGE, 3G, UMTS, Wifi, etc) or GPS. If you have GPS enabled you'll get better location than only network, which gives you a range, a circle where you are in.