簡體   English   中英

Android:如何獲取Cell Network Provider位置

[英]Android: How to get Cell Network Provider Location

我對獲取位置有非常基本的了解。 我的要求是在沒有啟用Wifi或Gps的情況下獲取Cell Network Provider Location。 我只需要獲得基於Cell Network Provider的位置。 那可能嗎? 如果是的話,請你幫我一些代碼片段。 我感謝您的幫助。 謝謝。

看看這個帖子在這里

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

}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM