onLocationChanged not called on some devices

后端 未结 7 1491
悲哀的现实
悲哀的现实 2020-12-30 01:38

This is a question which has been asked numerous times but I could not find a solution that always works.

I am developing an application using the Fused location pro

相关标签:
7条回答
  • 2020-12-30 02:17

    Here Check this code out...

    public class MyActivity extends Activity implements LocationListener {
    double destLat, destLong;
    
    LocationManager locationManager;
    
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    
        locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
        locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, this);
    
    }
    
    @Override
    public void onLocationChanged(Location location) {
        // TODO Auto-generated method stub
        destLat = location.getLatitude();
        destLong = location.getLongitude();
    }
    
    @Override
    public void onProviderDisabled(String provider) {
        // TODO Auto-generated method stub
    
    }
    
    @Override
    public void onProviderEnabled(String provider) {
        // TODO Auto-generated method stub
    
    }
    
    @Override
    public void onStatusChanged(String provider, int status, Bundle extras) {
        // TODO Auto-generated method stub
    
    }
    
    0 讨论(0)
提交回复
热议问题