【问题标题】:Android: How to get Cell Network Provider LocationAndroid:如何获取手机网络提供商位置
【发布时间】:2010-12-26 05:41:13
【问题描述】:

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

【问题讨论】:

    标签: android location


    【解决方案1】:

    看看这个帖子here

    【讨论】:

    • 嗯....我认为该线程根本不相关。这个问题与获取基于网络的(cell-id,wifi)location有关。您提到的线程解释了如何获取可用网络运营商的列表。这与获取网络位置毫无关系。
    【解决方案2】:
    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;
    }
    

    }

    【讨论】:

      猜你喜欢
      • 2014-09-06
      • 1970-01-01
      • 2011-10-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-12-11
      • 2020-04-26
      相关资源
      最近更新 更多