我已经使用位置监听器编写了一个gps代码来捕获当前位置的纬度和经度,它对我的大多数设备都运行良好 . 但是某些设备(特别是三星)无法从位置监听器加载此纬度经度 . 这是我不断改变纬度和经度的代码 .

公共类MyLocationListner实现LocationListener {

public void onLocationChanged(Location location) {
    // TODO Auto-generated method stub

    String getLatitude = "" + location.getLatitude();
    String getLongitude = "" + location.getLongitude();


    double x = location.getLatitude();
    double y = location.getLongitude();
    }

    @Override
    public void onProviderDisabled(String arg0) {
    // TODO Auto-generated method stub

    }

    @Override
    public void onProviderEnabled(String arg0) {
    // TODO Auto-generated method stub

    }

    @Override
    public void onStatusChanged(String arg0, int arg1, Bundle arg2) {
    // TODO Auto-generated method stub

    }

}

要调用上面的位置监听器,我在我的活动中使用下面的代码片段 .

强调文本{LocationManager location_manager =(LocationManager)getApplicationContext() . getSystemService(Context.LOCATION_SERVICE); LocationListener listner = new MyLocationListner(); location_manager.requestLocationUpdates(LocationManager.GPS_PROVIDER,0,0,listner);}

请给出解决方案为什么它不起作用 .

提前致谢