How to Find GPS Signal is Lost in Android? - android

Is there a way to find out that the GPS signal is lost? I am not talking about whether GPS Module is enabled/disabled. Suppose that GPS Module is enabled; but fix is lost?
This How can I check the current status of the GPS receiver? link is not useful; since you cannot use that solution in the case which user is stationary for a certain period of time("LocationListener" stops listening to location updates; after you receive couple of updates upon first fix).
More than that, unlike on gingerbread, on my Nexus 4(which has Jelly Bean 4.2.2) "onStatusChanged" method of "LocationListener" is not called anymore! I dont know whether it depends on being stationary or not; yet it doesn't mean anything for me again.
On the other hand, My API is compiled via API 10, however in that release, no action called "GPS_FIX_CHANGE" had been declared in "LocationManager" class at that time.
What should i do to have my app notified of signal lost and gained events?
Kind Regards

Android and iphone both have a stand still filter enabled, which as you described, leads to the situation that you don't get a location update when standing still.
I would just ignore that, and use the Location.accuracy value for each new location received. If that values exceeds 30m then it is bad GPS.
While standing you could decide to do nothing.
Theoretically there is a solution for your task, but with drawbacks:
When you don't get a new location for some time, you can disable and reenable Location Service every 5 seconds. Then in case of good GPS you get a new coordinate, or none if there is no GPS signal available.

I've encountered this same issue and came to this conclusion: when the GPS signal is lost the listener will return the last value or 0.0 (in some situations). If the last 2 values are equal to the last 5th decimal then the signal is lost. In practice the GPS will never give you two consecutive coordinates with the same value. It's close to impossible, so just consider this case if(last_coords == new_coords) -> GPS signal lost.

Related

Getting wrong Gps Location in android

I am using GPS to fetch location at 15 second interval in my android application. It is giving correct data but sometimes it fetches forward location and after that again fetches backward location. In result i am getting wrong track on google map.
Please help.
Your question is a little big vague...
The problem with GPS is that it is highly dependent on your whereabouts. Things such as tall buildings and sometimes even large trees can have a major impact on your GPS readings. Being inside a structure or outside is also another major factor which must be considered. Also, most of the time, the GPS will return different GPS co-ordinates even if you stay in the same place.
The average margin of error of a GPS usually varies between 5 and 50m. When you say 'forward' and 'backward' location, I am assuming that you mean that the GPS is returning a value for a position which is either ahead of you or behind you.
The fact that, as you say, the GPS most of the time works, leads me to suspect that the issue you are experiencing varies depending on your actual physical location, however, due to the vague nature of your question we can only speculate...
My suggestion is that you try this out in various places, maybe some with clear access to the sky, and another in a crowded area and you see how the GPS behaves.
I too faced same problem while testing my Google navigation app.
The wrong location from GPS receiver is due to the lack of signal reception from GPS Satellites to GPS receiver.
This is due to the position of your GPS receiver device and also depends on the quality of GPS receiver.

Why is locationmanager returning old location fixes with new gettime-timestamp?

We have an app that upon user action tries to get a location fix. It listens both on GPS and network and has a time/accuracy based decision matrix to determine when to stop listening and what fix to return.
We have noticed, on occasion, a very strange behaviour. We use the classic way to see how old the fix is, like so:
long age = now - newLocation.getTime();
if(age >= prefs.getLocationMaxAge()){
Log.d(TAG, "location too old.");
return;
}
But sometimes, the location.getTime returned from the OS has an age of perhaps 15-20 seconds, according to the returned timestamp, although we can tell for certain that it's very old. For example, if the longitude/latitude fix is from a position that the handset was on 30 minutes ago!
It seems to happen both from Wi-Fi and network, but not GPS. To me, this is totally crazy. Has anyone else seen this and is there any way around it?
We have gotten it on a couple of different phones, most recent one is Samsung Galaxy S II.
Help would be extremely welcome.
EDIT: To be really clear, the problem is that the "onlocationchanged" callback gets called by the OS with a location with a timestamp age of perhaps a couple of seconds, when I know for certain that the longitude/latitude in the "new" fix is a place where the phone hasn't been at for at least 30 minutes.
This makes it kind of hard to accurately determine where the handset it...
It seems to happen both from Wi-Fi and network, but not GPS
This seems fair, because in the Wi-Fi and network cell-site based triangulation, the accuracy is very bad. They are probably using cached locations which date back to 30 minutes ago. Unless you have not changed your cell-site or moved to another building so that new APs can be discovered, I'm afraid you will get only cached locations. If you want fresh locations use the GPS provider.

Can I get Android GPS information with very few satellites?

Using a GPS app I find that inside a car I get maybe 3 satellites with low quality signals. The GPS never locks and so nothing that requires GPS will work. The GPS app says that it gets 0 feet accuracy which means that an app that requires GPS would never be notified of a successful GPS signal.
In an app is there any way to get very rough GPS information when the signal quality is low? The app I'm writing would work very well if all I could do is get a rough speed and direction. I don't need pinpoint information.
I know I can use cell signals for location information, but that information is useless for getting speed and direction. I can't find any example code for using the accelerometer to get rough information, but even if I did it would only work if the app was started when the car was stopped (so it could detect the acceleration).
If I could get a very rough signal I should be able to calculate speed and direction, yet there doesn't seem to be a way to register a listener for that.
To get speed only GPS_PROVIDER can help. All you can do is to set minTime as well as minDistance to 0. i.e. requestLocationUpdates (LocationManager.GPS_PROVIDER, 0, 0, listener) Do not put any criterias. This will make best use of GPS hardware chip inside your android. This would however drain battery much faster. I had observed that after getting 1st GPS fix even if you move a little inside of room, the flow of GPS updates still continues, where it would otherwise never would able to get a fix. Regarding of getting direction while in motion, if you know the position of device inside car, you could consider of keeping track of accelerometer readings, and with the help of orientation listener check on which axis you get the jerks more, then this will give you the direction of motion.
Technically, if you can get an okay signal from 3 satellites, you can get a fix. I'm not sure if such a low-quality fix is enabled on Android or not, but it is possible.
Regarding the accelerometer, it is not accurate enough to get an idea of direction. You will find too much noise, if anything from vibration.
Perhaps you should interface with a bluetooth GPS on top of the vehicle.
I'm not aware of any way to get a 'low quality' signal. In my own app I've noticed that GPS normally receives its first fix once I have 6-7+ satellites but this could vary (I've never seen a fix with only 3).
You really can't determine if you have a fix based on how many satellites are connected to.
I think you need four satellites to get a proper GPS reading (one for each variable in the GPS equation), but many of the Android devices on the market have access to the magnetometer. If you calibrate it (waving in a figure-8 for 4 or 5 cycles), you can get a pretty accurate direction determination using the "compass".
Other than using the GPS, I don't know of any technique of calculating speed.

GPS update interval is faster with good signal?

I'm trying to limit my program to take location updates every 10 seconds instead of constant updates in order to reduce battery drain. This works fine when i'm debugging indoors and the signal is weak (i.e. the GPS icon flashes), but if the phone gets a proper fix (i.e. the GPS icon is static) the update interval increases to roughly a second.
I know that the code mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, updateInterval*1000, 0, this); will not force the GPS to take updates exactly at the given interval, but in my opinion it shouldn't depend on the strength of the signal and fluctuate that much.
Any ideas?
UPDATE: see comment
I suspect that the GPS radio works in a manner where either it's connected to GPS satellites or it's not. When it's connected, the Android SDK sends you updates as frequently as they're available from the GPS hardware. When it doesn't have a full GPS connection it falls back to sending AGPS updates according to what you've requested.
If you only want updates every 10 seconds, you should save the last received Location's time value in your listener, and when you receive a new Location check its time against the old value; ignore it if it's too frequent (or do something smarter like checking the accuracy and replacing the old value, etc).
Maybe it works slower because you are debugging, but not because your signal is weak! Try to make tests with disconnected debugger indoors...

Periodically check if android GPS has new data

I have successfully been getting GPS data through the registerLocationListener() and onLocationChanged() methods. The only problem with this is that the speed reading of my app freezes if there is no more GPS data (e.g. when I go indoors, enter a tunnel, etc). The behavior I want for my app is that the user is somehow notified that the speed reading is probably not accurate due to a lack of fresh data (set speed to zero, blink the speed reading, etc).
How can I do that? I though of checking periodically whether the GPS unit was detecting any satellites, but I'm not sure how to force periodic checks.
Maybe you could just start a periodic timer. If timer sees that last GPS fix is old it displays notification. Application should remember when the last fix was.

Categories

Resources