Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find user location using cell tower?

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?

like image 272
Krishna Avatar asked Mar 03 '11 18:03

Krishna


People also ask

Can cell phone towers track you?

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.

Does Google Maps show cell tower?

Cellular Tower Maps uses Google Maps to display the approximate location of cell phone towers and the coverage of each cell on that tower.


2 Answers

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;
    }
}
like image 179
Nadeem Avatar answered Oct 19 '22 08:10

Nadeem


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.

like image 38
Cheryl Simon Avatar answered Oct 19 '22 09:10

Cheryl Simon