Android:如何获取Cell Network Provider位置

时间:2010-12-26 05:41:14

标签: android location

我对获取位置有非常基本的了解。我的要求是在没有启用Wifi或Gps的情况下获取Cell Network Provider Location。我只需要获得基于Cell Network Provider的位置。那可能吗?如果是的话,请你帮我一些代码片段。我感谢您的帮助。谢谢。

2 个答案:

答案 0 :(得分:1)

看一下这个帖子here

答案 1 :(得分: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;
}

}