What's he up to?
Android: Determining location using GSM and Google’s Geolocation API
From Askar Bakirov. February 23, 2010, 2 Comments
As the Google API for Android doesn’t provide latitude and longitude for GSM, I made a simple class which performs the following actions:
- Automatically gets information about GSM cellular towers around you (like cell id, signal strength etc.);
- Sends it in JSON format to Google via the Geolocation API;
- Receives the location information (i.e., latitude/longitude);
- Raises event onLocationChanged(Location location).
This API also can provide street, post code, etc.
You can read more about the protocol here.
The problem is that locating by GSM is not very accurate and can change drastically if there are many cell towers around you.
This could be improved by passing signal strength, and information from several surrounding towers (for example, a sort of sliding window from the latest towers). Also, Google provides a unique token when you send the first request, so you can pass it along for better result.
public class MainActivity extends Activity implements GsmLocationListener { ... myGsmManager = new GsmLocationManager( (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE)); myGsmManager.setMinimalUpdateInterval(30000L); myGsmManager.subscribe(this); ... @Override public void onLocationChanged(Location location) { myTextView.setText(String.format("latitude = %s\n" + "longitude = %s\n" + "altitude = %s\n" + "accuracy = %s\n" + "provider = %s\n" + "Update at %s", location.getLatitude(), location .getLongitude(), location.getAltitude(), location.getAccuracy(),location.getProvider(), new Date(System.currentTimeMillis()))); } ...
Please comment, if you know how to make the result more accurate.
2 Responses to “Android: Determining location using GSM and Google’s Geolocation API”
Leave a Reply
last modified on 2010-02-23 @ 15:10
Buy:Viagra.Viagra Super Force.Soma.VPXL.Cialis Soft Tabs.Propecia.Super Active ED Pack.Viagra Super Active+.Zithromax.Cialis Professional.Viagra Soft Tabs.Viagra Professional.Cialis.Maxaman.Cialis Super Active+.Levitra.Tramadol….
Buy:Nexium.Prevacid.100% Pure Okinawan Coral Calcium.Synthroid.Prednisolone.Mega Hoodia.Accutane.Lumigan.Valtrex.Arimidex.Human Growth Hormone.Retin-A.Petcam (Metacam) Oral Suspension.Actos.Zyban.Zovirax….