NETWORK_PROVIDER方式如何获取经纬度呢?总是为null

解决方案 »

  1.   

    联通的卡吧?2.3以下的API版本吧?
      

  2.   

    to:guanwaterbighao
    是联通的3G卡, 是2.2的API,  请问跟服务商和API具体有什么关系呢? 
      

  3.   

    To: yangting_lisa
    程序onClick中如下:
    LocationManager locationManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
    Location location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
    locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 2000, 0, locationListener);
    if (location != null) {
    double lat = location.getLatitude();
    double lng = location.getLongitude();
    }
    监听器中为如下:
    private final LocationListener locationListener = new LocationListener() {
    public void onLocationChanged(Location location) {
    if (location != null) {
    double lat = location.getLatitude();
    double lng = location.getLongitude();
                            }
    }
    };
      

  4.   

    这个貌似和硬件以及系统有关系吧,我用htc的港行g20试过是可以的,用华为和moto defy则不行,有没有高手解释下是什么原因。