3

I have a very basic knowledge on getting the location. My requirement is to get the Cell Network Provider Location without having Wifi or Gps enabled. I just need to get the location based on Cell Network Provider. Is that possible? If yes, could you please help me with some code snippets. I appreciate your help. Thanks.

Vivek
  • 4,526
  • 17
  • 56
  • 69

2 Answers2

1

Have a look at this thread here

Community
  • 1
  • 1
ninjasense
  • 13,756
  • 19
  • 75
  • 92
  • 1
    Hmmm....I don't think that thread is relevant at all. The question is related to getting network-based (cell-id, wifi) **location**. The thread you've referred to explains how to get a list of available network operators. That has nothing at all to do with getting network **location**. – David Wasser Mar 22 '12 at 12:01
0
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;
}

}

benka
  • 4,732
  • 35
  • 47
  • 58