aspose file tools*
The moose likes Android and the fly likes GPS Accuracy Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Mobile » Android
Bookmark "GPS Accuracy" Watch "GPS Accuracy" New topic
Author

GPS Accuracy

Chris Mack
Greenhorn

Joined: Feb 24, 2009
Posts: 13
Hi, all. I am developing an application for Android that gets the latitude and longitude of where the person is standing at a certain point in time.
I wrote a test application. When I run the application, it appears to work fine, except the accuracy prints out 300 meters sometimes.

I go into Google Maps application and it has me within a few meters of my location on the map...It's pretty accuracte.
So my questions is, how is Google's coordinates so accurate when my application reports the reading being off by 300 meters?
Does Google massage the data some how to make it more accurate? Am I missing something in my code?

I need these readings to as accurate as possible. I also print the provider to the screen and it displays gps, so I believe I am not using the network (cell towers).

Here is how I am doing it.

First, I create a LocationManager : LocationManager lm = (LocationManager)getSystemService(Context.LOCATION_SERVICE);

Then I get the provider using a Criteria Object:

Criteria criteria = new Criteria();
criteria.setAccuracy(Criteria.ACCURACY_FINE);
criteria.setPowerRequirement(Criteria.NO_REQUIREMENT);
String bestProvider = lm.getBestProvider(criteria, true);

Once I have the provider, I create my own location listener:

locationListener = new MyLocationListener();

private class MyLocationListener implements LocationListener {

public void onLocationChanged(Location loc) {
if (loc != null) {
Toast.makeText(getBaseContext(),
"Lat: " + loc.getLatitude() +
"\nLng: " + loc.getLongitude()+
"\nProvider: "+loc.getProvider()+
"\nAccuracy: "+loc.getAccuracy(),
Toast.LENGTH_SHORT).show();
}
}
....
}

Then I make a request for location updates:
lm.requestLocationUpdates(provider, 0, 0, locationListener, getMainLooper());




Any suggestions?

Thanks,

Chris
Dave Brown
Ranch Hand

Joined: Mar 08, 2005
Posts: 301
Is it possible google maps is detecting your position using wifi and not your GPS?


Regards, Dave Brown
SCJP 6 - [url]http://www.dbws.net/[/url] - Check out Grails Forum
Chris Mack
Greenhorn

Joined: Feb 24, 2009
Posts: 13
I turned WiFi off because I know that Google Maps can use SkyHook via the WiFi. I think I would also have to be logged onto a network in order for it to use SkyHook via WiFi. I still have the same issue with WiFI turned off.

Thanks for your reply.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16137
    
  21

I'm not certain how closely Android's GPS feature matches the JSR GPS spec, but the JSR version of GPS allows the client to select from multiple location service providers. And, by the way, it is Location Services, not GPS. GPS is a particular kind of location service.

The distinction is important, because with cell phones, one of the more popular location services is Trilateration. Which is a means of detecting position by triangulation one's position relative to cell phone towers. On the Sprint network at least, trilateration's accuracy is only guaranteed to - wait for it - 300 meters.

Why use trilateration instead of GPS? Some (mostly older devices) didn't have GPS hardware. Sprint and Verizon often disable the GPS hardware to prolong battery life. And sometimes, you just can't collect enough satellites to use GPS, especially indoors.

Obviously, trilateration has its own limits. If you're out of range of cell service, it won't work at all, although in crowded areas, it may actually be much more precise than 300 meters. It's just one of the options.

If I remember correctly, the Androd location services allow selecting for more/loss accurate location services, so if to-the-centimeter accuracy is critical, be sure you request the fine-grained location service. How fine the actual resolution will be can vary, but the most accurate source available will be used.

Oh yes, and you may have to explicitly select for true GPS on your phone. I think it's turned off by default on mine. As I said, GPS can suck down some power.


Customer surveys are for companies who didn't pay proper attention to begin with.
Chris Mack
Greenhorn

Joined: Feb 24, 2009
Posts: 13
Thank you for your reply. I found that when I turned on the phone and started my app. when indoors and then walked outside, the accuracy stayed at about 300 meters. When I went outside and then opened my app., the accuracy got better, down to 3 meters. I didn't think that being inside would make such a difference. I expected some variation, just not that much.

Your response was educational as well. I knew about triangulation but I did not know about trilateration.

Thanks again.

Chris
Tushar Arsekar
Greenhorn

Joined: Jun 15, 2010
Posts: 8
I had recently developed a Android GPS tracking program on the same lines as you did.

I am using Android Samung phone and when I turned on GPS along with Network, it seems to consider the network settings first over the GPS.

Network setttings will showed inaccurate position of about 100-150 meters.

When I disabled the network settings and kept the GPS on, it gave me the correct position.

Also GPS settings work accurately outside the house or in open sky area.

Thanks,
Tushar
Oracle SOA Architect Certified Expert.
Oracle Certified Master, Java EE 5 Enterprise Architect certification
IBM Certified Rational Software Architect.
IBM Certified Service Oriented Architecture (SOA) - Associate.
IBM Websphere MQ 6.0 Certified - System Adminstrator
Sun Certified Web Component Developer for J2EE 5.0.
Sun Certified Java Programmer SE 5.0.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: GPS Accuracy