I create a LocationListener and register it with the LocationManager to receive changes in the location, but a problem arises: no answers come to the listener's methods! Totally! Here is the creation code:
LocationListener listener = new LocationListener() { @Override public void onLocationChanged(Location location) { if (lastLocation == null) { lastLocation = location; } distanceInMeters += location.distanceTo(lastLocation); lastLocation = location; Log.i(TAG, "LocationChanged"); } @Override public void onStatusChanged(String provider, int status, Bundle extras) { Log.i(TAG, "StatusChanged"); } @Override public void onProviderEnabled(String provider) { Log.i(TAG, "ProviderEnabled"); } @Override public void onProviderDisabled(String provider) { Log.i(TAG, "ProviderDisabled"); } }; LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { Log.i(TAG, "FCK..."); return; } locationManager.requestLocationUpdates(locationManager.GPS_PROVIDER, 1000, 1, listener); Why the listener does not work and how to fix it?
PS GPS - turned on.
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>, and the other go now no ... - user189127onProviderDisabled... - user189127