I am trying find out the speed and altitude in android without using getspeed() and getAltitude() methods. If any one has any reference material or code snippet with respect to this,please share it so that it can be of some help to me.
Speed can be done by keeping track of location on subsequent updates, finding the distance between them, and dividing by the time difference. Altitude- good luck, you'd need signal strength info that I don't think you can get. You really don't want to do it.
Related
I tried to understand the effect of hasSpeed() function in android(Locatio), but i still stuck at this point ,anyone clarify my doubt ?
Simply put, it's the physically moving speed of the location provider. For example, this can be used to calculate the movement speed of a device using the GPS. You can read more on the official docs for Location Strategies.
For my Android app I need to determine when the user increases its speed and when it decreases it, I don't need to find the exact speed value, only know if it has increased, decreased or it's the same.
The first solution I came up with was to register a listener for GPS and in the onLocationChanged() method calculate the speed and then check to see if it was greater or equal, but it didn't worked, beacuase the speed was very inaccurate.
Another solution I tried was to use the accelerometer to measure the steps in two seconds, and compare that measure to the previous one, to see what was greater, but I didn't found an exact algorithm. I found some approximation from Android pedometer Github code sample: https://github.com/bagilevi/android-pedometer , but it wasn't too accurate.
So, what solution should I use? What's the most effective way of counting steps with accelerometer?
Thank you.
i'm looking for the best way to implement a road navigator that gets the velocity, distance between 2 points using the smartphones techniques.
through my searches i found 2 different tech. using either the accelerometer or android API (android.Location).
some opinions said that using accelerometer wont give me an accurate results because there will be so much noises as a bumpy roads, buildings...etc and calculations will be so complex.
on the other hand using the Android API (android.Location) means i should always be connected to the GPS, doesn't that affect on the battery?!! and as i found i can't open the GPS by myself i used always ask the user for a permission(so boring). and is there an limitation
So kindly help to take a decision, is it useful to be connected 24 hours on GPS in order to update the device location.. or to use the accelerometer??
You definitely should use GPS. The battery will be strained but you get much more accurate result. Sensor should be used only when GPS is not available and for a short distance.
Using GPS you can call location.hasSpeed() and if positive call location.getSpeed() together with getBearing() will give you the velocity.
I a trying to create an application that will be able to guide people in a city, with points of interest. For this, I need the better accuracy I get, in order not to place POI where there is nothing...
To do this I use droidAR (it gives me a radar, and I can place my POI thanks to their coordinates). But the accuracy is so bad I can't see how this can used.
For exemple, to determine if I a close to a POI, I calculate the distance between it and my GPS position. It can be that, with a 10 meters accuracy given by Android when I place the POI, it is then 80 meters away when I try to find it.
SO I looked forward to find another position systems, I found :
skyhook, which is supposed to give a more accurate position. With this, I took 1000 points and checked their distance to the last point, it is always moving and it was sometimes 300m away, so it seems even less precise. Maybe anyone could use it successfully ?
someone told me to use DCM algo (Direct Cosine Matrix), that can give me an accurate relative position (no problem for my use cases to do every positioninf relative to a start point). Some drones are using it, it could reach 1 meter accuracy. But I couldn't find any implementation or help with Android.
Did anyone succeed into using the android GPS with accuracy ?
Either your android phone has a bad GPS device, or more probably you are doing something wrong. you can set a POI in city aprox. 5m acuracy, sometimes 20m. that is sufficient. check it with another GPS app that allows setting a waypoint.
In your app you could concentrate on the 95% GPS accuracy. There is nothing better than GPS (espcecialla yon a mobile phone), the other methods you described are for short time assistance to GPS, but they will not work good for pedestrians, they are made for vehicles (vehicles move straight most of the times, they cannot change its direction so fast like a human does).
Your problem is not the GPS location accuracy, it is the augmented reality projection of droidAR.
This seems like it should be simple enough, but I can't seem to get a clear example of how to calculate my speed using Android's Location Services.
All I want to do is calculate my speed based on my previous and current GPS position. getSpeed() doesn't work, because it needs to be set at some point using setSpeed().
So is there any sample code out there that I can run in Eclipse against my Android emulator running a GPX file, that will show me my pace in any measure (meters, feet, miles, etc., doesn't matter - I can always convert this to what I need).
Thanks in advance,
Alex
Do you just mean something like this? Gives you the speed in m/s.
oldLocation.distanceTo(newLocation) / (newLocation.getTime() - oldLocation.getTime())
getSpeed() doesn't work, because it needs to be set at some point using setSpeed().
(In case you are using an actual device -- ). No, the speed is determined by the GPS chipset and it should be more accurate than getting the distance and time between two consecutive locations. You do not need to setSpeed() . Call hasSpeed() to see if the speed is valid.
(In case you're not using an actual device)
I've had good success using the mock location provider where you can set the Location object you want with setSpeed() in meters/second
Here are some ways of doing this :
Mocking using NMEA
Mocking using code