How to find the user location using the cell tower in Android, or how to get the cell location based on the Cell ID in Android?
There are numerous ways your smartphone can be used to track your location including through the apps you install and use, but most of the time, this is done using cell towers or wireless networks.
Cellular Tower Maps uses Google Maps to display the approximate location of cell phone towers and the coverage of each cell on that tower.
class MyLocationActivity
extends MapActivity {
MapController mapController;
MyPositionOverlay positionOverlay;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
MapView mapView = (MapView) findViewById(R.id.mapview);
mapController = mapView.getController();
// Configure the map display options
mapView.setSatellite(true);
mapView.setStreetView(true);
mapView.displayZoomControls(false);
mapController.setZoom(17);
// Add the MyPositionOverlay
positionOverlay = new MyPositionOverlay();
List<Overlay> overlays = mapView.getOverlays();
overlays.add(positionOverlay);
LocationManager locationmanager;
String context=Context.LOCATION_SERVICE;
locationmanager=(LocationManager) getSystemService(context);
String provider=LocationManager.NETWORK_PROVIDER;
Location location= locationmanager.getLastKnownLocation(provider);
updateWithNewLocation(location);
}
private void updateWithNewLocation(Location location) {
if(location!=null){
positionOverlay.setLocation(location);
Double lat=location.getLatitude()*1E6;
Double lon=location.getLongitude()*1E6;
GeoPoint point = new GeoPoint(lat.intValue(),lon.intValue());
mapController.animateTo(point);
}
else{
}
}
@Override
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}
}
Use the LocationManager to register for location updates. You indicate which level of granularity you want by specifying a provider. For cell tower updates, use the NETWORK_PROVIDER.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With