Android location using Cell Tower

android

Solution

  TelephonyManager telephonyManager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
  GsmCellLocation cellLocation = (GsmCellLocation)telephonyManager.getCellLocation();

  int cellid= cellLocation.getCid();
  int celllac = cellLocation.getLac();

 Log.d("CellLocation", cellLocation.toString());
 Log.d("GSM CELL ID",  String.valueOf(cellid));
 Log.d("GSM Location Code", String.valueOf(celllac));

Make sure that you have those permissions in your manifest.

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>

If you really want the real position use a httpclient or somewhat to query http://www.google.com/glm/mmap with your cellid and lac. Example is listed here. http://www.anddev.org/poor_mans_gps_-celltowerid-_location_area_code_-lookup-t257.html

Problem

How can I retrieve my location using cell towers? when GPS and Wifi is off. I know i can retrevive cellID of towers, but how can i map it to get Latitude and Longitude of my current location? I don't care if it isn't accurate location. I have found some snippets but seems using wifi.

Original source