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.
Related
There may be similar questions regarding this topic,But I need your thoughts and suggestions on some specific requirement.
Here is my need -
We are developing one app which tracks User's trip.
The app will start collecting the location of that user in background,When user 'Starts' his trip from App.Background Service will be fetching locations on the basis of user's movement in specific time duration.
When User 'Stops' his trip from App,We are calculating distance traveled by user with help of all recorded locations(With Google Distance calculating API).
The App works fine in ideal case.
But main challenge is -
In some scenarios,We are not able to fetch exact and precise location of User. Scenarios affecting is - No internet,Data plan with 2g/3g,some specific areas where GPS is not returning accurate data etc.
Incorrect data of lat-long causes incorrect Trip distance and route.Which is main problem with the App.
Please,any one can suggest the best alternative/Suggestion for this?
P.S. - We have tried GPS,Network,FusedLocationProvider.
EDIT 2 --
We have implemented logic on basis of accuracy and distances.Got nearer points. And just came across one useful api from Google that corrects some location points which are distracted from actual Roads. Posting here for reference of others...
Snap to Roads Api from Google
this is a complicated topic.
One consideration you have to take. Android Oreo limits background services and that what you want to achieve won't work.
I would do is this (and it is the recommendation from Google)
When someone starts the trip (the user is aware of it), you must launch a on going notification with a foreground service , don't rely on background services anymore. Check the feature "Start Activity" in Google Fit App.
As for not having signal, or accurate GPS, well... it is a geographical problem!, there is nothing you could do. Or, maybe you can, using the LocationProvider.
FusedLocationProvider is fused within every app that requests locations updates.
Read this out, and see if that helps you.
https://developer.android.com/guide/topics/location/strategies.html
Try to mix GPS and Accelerometer
If you detect that GPS stopped working, turn on accelerometer. If GPS is turned on again, calculate distance again with it. This way you can have route with GPS parts and accelerometer ones. The bigger GPS parts, the more accurate data will be
How to get more accuracy by GPS_PROVIDER
Basically if the accuracy of a location isn't acceptable throw it away. The next one will be better.
My app works fine if the area has GPS (such as outside) or in houses/first or second floor buildings but it does not receive a location update if the area is something like the 4th-10th floor of a tall building, is this expected behavior or is this a limitation of location services?
Even with an internet connection on a high floor it still does not receive an update, this makes me believe that it is not falling back to Wi-Fi/mobile networks but I tried setting my Location method to Wi-Fi/Mobile only in the Android settings but it still works in normal environments.
Can anyone give me advice on what is happening? Do location services simply not work at higher altitudes or certain areas with very poor reception? I have not tested it in underground parking areas though.
I am using PRIORITY_HIGH_ACCURACY as my priority.
I am using PRIORITY_HIGH_ACCURACY as my priority.
That's the reason you are not getting Location change inside a building. Because HIGH_ACCURACY gets location from GPS provider. As we know GPS doesn't work well inside houses as it collects location from satellite.
You can try out other options.
PRIORITY_BALANCED_POWER_ACCURACY (About 100 meter)
PRIORITY_LOW_POWER (About 10km)
PRIORITY_NO_POWER (Act as a passive listener )
You may visit here if you havn't yet. Hope this helps.
I am in need to develop an android app where the device will track the distance traveled while the user is in a moving vehicle. I am getting the GPS values at small interval so that I can retrieve the distance and sum them up. But the problem I am facing is, while the user is in the vehicle, the device is not getting a clear view of the sky. Hence, the GPS device cannot get values as frequently as I desire. Thus, the result produced contains huge fluctuations. I tried using the network provider, but that is even worse in this scenario.
It would be very much helpful if anyone can suggest me a solution to this problem.
Just put the receiver onto the inner side of the windshield, like all navigation systems do. This should give an acuracy of about 3-6m. (when SBAS correction is available in your location) or up to 10m if not.
If the receiver is not state of the art (combined GPS + GLONASS or BEIDOU) then you will have problem in cities, especially in urban canyons with location jumps up to 30m.
This is normal. To get correct result for a GPS application within a city you need advanced algorithms. Just summing up the distance between two consecutive locations is to primitive, this never works well. Distance calculation by GPS has be answered some times her at SO. Use the search engine, to get more info at that topic.
Of course, set the device to GPS provider only, with maximum precision.
i wrote an app, that tracks the gps location while jogging. Unfortunately the app needs some time to get a gps signal. When i open other apps like google maps, they are getting immediately the position.
My Problem is: How to implement the gps-provider, so that the app gets as fast as possible a signal.
One idea was, to start a service with the app, so that the provider does some preliminary work. But the tracking-activity is not the main-activity. How can i bind the service in an activity, that does not have started the service? Is this a good idea?
Thanks for reading - and i hope my english is understandable,
Martini
As I mentioned in my comments, GPS start up is not an instant process. The receiver basically has to know the position of each of the GPS satellites in the constellation in order to calculate it's location. The ephemeris data describes the positions of the satellites to the received and is downloaded from the satellites when the GPS is turned on (and I almost forgot to mention the almanac data, which is also part of the download and describes the orbits of the satellites). Things like downloading from multiple satellites and using the last known position can help speed up this initial process, but you cannot make it "instant".
There are other strategies that can be used to help speed up the location process, especially in cell phones. In addition to the last-known position, things like Cell Tower + Timing positioning (ECID) or Wi-Fi positioning can be used in place of GPS while the GPS is still in the acquisition process.
This link describes some ideas on how to handle locating a mobile phone in android, but the short of it is:
check last known position (discard if it is too old)
check E-CID position (this is extremely fast, but is a very coarse
location)
check Wi-Fi position (this can be extremely accurate, but requires WiFi to be on and can sometimes have a large amount of error)
finally obtain GPS position
Are you first checking if there is a last known location which you can use? Most apps first check for it and then search for a location.
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.