mrmans0n / smart-location-lib

Android library project that lets you manage the location updates to be as painless as possible
1.65k stars 353 forks source link

It's not calling OnLocationUpdatedListener #189

Open freebumba27 opened 7 years ago

freebumba27 commented 7 years ago

It's never calling OnLocationUpdatedListener even I have added checking because I am testing it in >23

   if (ContextCompat.checkSelfPermission(this,
    != PackageManager.PERMISSION_GRANTED) {
    != PackageManager.PERMISSION_GRANTED) {
        SmartLocation.with(this).location()
                .oneFix()
                .start(new OnLocationUpdatedListener() {
                    @Override
                    public void onLocationUpdated(Location location) {
                        lat = location.getLatitude();
                        lng = location.getLongitude();
                        Log.d("TAG", "onLocationUpdated: lat: " + lat + " lng: " + lng);
                    }
                });
    }
joxad commented 7 years ago
   if (ContextCompat.checkSelfPermission(this)   == PackageManager.PERMISSION_GRANTED) {
        SmartLocation.with(this).location()
                .oneFix()
                .start(new OnLocationUpdatedListener() {
                    @Override
                    public void onLocationUpdated(Location location) {
                        lat = location.getLatitude();
                        lng = location.getLongitude();
                        Log.d("TAG", "onLocationUpdated: lat: " + lat + " lng: " + lng);
                    }
                });

And you need to add onPermissionResult in your activity

ghost commented 7 years ago

For me, it is calling only once. Where do I have to configure to constantly get the updates?

mecoFarid commented 7 years ago

@mrmans0n , onLocationUpdated called only once, any suggestions? P.S. setInterval(10L), I'm not moving though.