Android Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsMobile ProgrammingAndroid Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old July 9th, 2012, 02:31 PM
bransby bransby is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2012
Posts: 17 bransby User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 14 m 51 sec
Reputation Power: 0
Getting accurate GPS latitude and longitude

So I'm trying to get the most accurate location. It seems to be giving me a location about 2 miles away where I was yesterday.

Does anybody know how you can get about getting the phone to re calibrate where it is? The corresponding code is below.

Obviously there there is no defensive code yet.

Thank you in advance

Code:
public String getZipcode(){
		Location location = getMyLocation();
		double lat = location.getLatitude();
		double lng = location.getLongitude();
		List<Address> result = null;
		Address thisAddress = null;
		String zipcode = null;
		Geocoder g = new Geocoder(this,Locale.getDefault());
		try{
			result = g.getFromLocation(lat, lng, 1);
			thisAddress = result.get(i);
			zipcode = thisAddress.getPostalCode();
			}
		}catch(Exception e){}
		return zipcode;
	}

Reply With Quote
  #2  
Old July 9th, 2012, 06:16 PM
E-Oreo's Avatar
E-Oreo E-Oreo is offline
Lost in code
Click here for more information.
 
Join Date: Dec 2004
Posts: 7,931 E-Oreo User rank is General 90th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 90th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 90th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 90th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 90th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 90th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 90th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 90th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 90th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 90th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 90th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 90th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 90th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 90th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 90th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 90th Grade (Above 100000 Reputation Level)  Folding Points: 945 Folding Title: Novice Folder
Time spent in forums: 2 Months 7 h 43 m 47 sec
Reputation Power: 6991
What is getMyLocation() doing?

From a quick read of the API it looks like you should be binding a callback to a LocationManager and using that to obtain regular updates on the current location (which you might already be doing, I can't tell). My guess is that there is not a specific call you make to ask for a recalibration; either the recalibration happens automatically in all cases, or it only happens when you have an active handler bound to a LocationManager.

Another, perhaps more likely, possibility is that your LocationManager is set to only use GPS for location data and your phone is currently unable to obtain a GPS signal (for example, if you're testing inside a building). In that case the phone would probably return the last-known GPS location even if it differs from the phone's current location (as calculated using other metrics).
__________________
PHP FAQ
How to program a basic, secure login system using PHP

Quote:
Originally Posted by Spad
Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around

Reply With Quote
  #3  
Old July 11th, 2012, 05:00 PM
bransby bransby is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2012
Posts: 17 bransby User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 14 m 51 sec
Reputation Power: 0
My apologies. I forgot I threw that method in there. It is

Code:
private Location getMyLocation() {
		LocationManager lm = (LocationManager)getSystemService(Context.LOCATION_SERVICE); 
		return lm.getLastKnownLocation(LocationManager.GPS_PROVIDER);
	}


So looking at that, it still should get where I am especially since the GPS works fine for me and pinpoints where I am.

After trudging through the API, you're right there is no re calibrate but at the same time, if it is getting a GPS signal, it should grab where it is now.

Do you think maybe it's just that fickle?

Reply With Quote
Reply

Viewing: Dev Shed ForumsMobile ProgrammingAndroid Development > Getting accurate GPS latitude and longitude

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap