Android: No location updates from NETWORK_PROVIDER on ICS - android

There are similar posts on this issue. It seems to be related to some devices running ICS and above that after a while (device entering "sleep mode"-if there is one?) there are no location updates from the NETWORK_PROVIDER any more even though Network provider is enabled. The GPS_PROVIDER still works just fine in open air. Have tried to toggle Wifi and such, but the only thing that seems to help is to reboot the device. Must be a solution for this?

Related

Working with GPS via libhardware on Android

In AOSP there is libhardare library which contains interface to the GPS driver - gps.h. Using this interface you can get access to GPS driver on low level (C++), turn on GPS and get current location of the device.
On the Internet there are several projects, that use this GPS interface. For example, this one created by kanru. This code works almost perfectly - I could connect to GPS driver and get correct location.
But I ran into a problem. If you turn on GPS driver using kanru project and after awhile turn on GPS via standard method (in GUI), then C++ program will suddenly stop receive information from GPS driver. At the same time in GUI you can see that GPS is On and you can start Google Maps or any other GPS-related application and get your coordinates.
I tried to restart GpsInterface, turn off and on GPS driver via hw_device_t pointer, even restart whole C++ executable - no effect.
After restart of the program GPS driver change status to GPS_STATUS_ENGINE_ON and then - silence.
Also I tried to change the order of actions. I turned on GPS in GUI, launched Google Maps and waited several minutes till I got my location. Then I started my C++ program. It successfully connected to GPS driver and started to get location data. Meanwhile GUI "lost" connection with GPS driver.
I tried to test my program on several devices with Android 4.2 and 5.1 and get same problem on the most of them. Only on Samsung S6 with Android 5.1 my program was able to work perfectly under all conditions.
It seems like on some devices GPS driver configured so that it can work with only one data consumer.
Perhaps someone faced a similar problem?

Android's meaning of turning location on/off

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.

Android NETWORK_PROVIDER returns null. Until Phone Restarted

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?

Browser geolocation - Android 2.3.4 ignores GPS satellites. How to fix?

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.

Has NETWORK_PROVIDER behavior changed in Android 4.1.1?

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.

Categories

Resources