Android:如何获取基站位置信息

3

我对获取位置的基础知识很浅显。我的需求是在没有启用Wifi或Gps的情况下获取蜂窝网络提供商的位置。我只需要根据蜂窝网络提供商获取位置。这种可能吗?如果是,你能否帮我提供一些代码片段。感谢你的帮助。

2个回答

1

1
嗯...我认为那个线程根本不相关。问题与获取基于网络的(cell-id,wifi)位置有关。您所提到的线程解释了如何获取可用网络运营商列表。这与获取网络位置毫无关系。 - David Wasser

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;
}

}


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接