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.
精彩评论