After the release of Oreo 8.0 and 8.1 i updated my targetSdkVersion into 27 because Notification channel is necessary for foreGround Services, but unfortunately FusedLocationProviderClient stops working if the device is not connected in internet but will only resume when it's connected again in internet. The Service is still running and so thus the Notification is still there. I've tried searching for answers but i haven't seen any related to my problem, maybe it's because SDKversion 27 is the latest one if i'm not mistaken. Here's how i did the FusedLocationProviderClient. Thank you in advance
long interval=locationInterval*1000L;
final LocationRequest locationRequest=
LocationRequest.create()
.setInterval(interval)
.setFastestInterval(interval)
.setSmallestDisplacement(0)
.setPriority(getLocationRequestPriority);
// Create LocationSettingsRequest object using location request
LocationSettingsRequest.Builder builder = new
LocationSettingsRequest.Builder();
builder.addLocationRequest(locationRequest);
LocationSettingsRequest locationSettingsRequest = builder.build();
final SettingsClient settingsClient =
LocationServices.getSettingsClient(context);
settingsClient.checkLocationSettings(locationSettingsRequest);
mLocationCallback = new LocationCallback() {
@Override
public void onLocationResult(LocationResult locationResult) {
super.onLocationResult(locationResult);
startTrackingUserActivity();
evaluateLoopEvent(locationResult.getLastLocation(),context);
}
};
fusedLocationProviderClient.requestLocationUpdates(locationRequest,
mLocationCallback,
null /* Looper */);
NOTE: all working fine in 6.0 and up, not working in 5.0 only. Below are the logs after i close the wifi, but it seems that these are not quite related to the problem i guess, but just to make sure:
10-11 17:29:37.556 3553-9897/com.mypackage D/OpenGLRenderer: DisplayEventReceiver 0xb0615050 requestNextVsync
10-11 17:29:37.564 3553-3572/com.mypackage I/art: Background partial concurrent mark sweep GC freed 44149(2MB) AllocSpace objects, 0(0B) LOS objects, 14% free, 23MB/27MB, paused 1.398ms total 122.731ms
10-11 17:29:37.572 3553-9897/com.mypackage D/OpenGLRenderer: DisplayEventReceiver 0xb0615050 latestVsyncEvent 7443515544577
10-11 17:29:58.061 3553-9897/com.mypackage D/OpenGLRenderer: DisplayEventReceiver 0xb0615050 requestNextVsync
10-11 17:29:58.062 3553-9897/com.mypackage D/OpenGLRenderer: DisplayEventReceiver 0xb0615050 latestVsyncEvent 7464005223098
10-11 17:30:20.936 3553-3572/com.mypackage I/art: Background partial concurrent mark sweep GC freed 57947(3MB) AllocSpace objects, 0(0B) LOS objects, 15% free, 22MB/26MB, paused 1.815ms total 130.586ms
10-11 17:30:55.554 3553-9897/com.mypackage D/OpenGLRenderer: DisplayEventReceiver 0xb0615050 requestNextVsync
10-11 17:30:55.569 3553-9897/com.mypackage D/OpenGLRenderer: DisplayEventReceiver 0xb0615050 latestVsyncEvent 7521510589393
10-11 17:31:05.212 3553-3572/com.mypackage I/art: Background partial concurrent mark sweep GC freed 37227(2MB) AllocSpace objects, 0(0B) LOS objects, 15% free, 22MB/26MB, paused 1.884ms total 102.828ms
10-11 17:31:47.335 3553-3572/com.mypackage I/art: Background partial concurrent mark sweep GC freed 36922(2MB) AllocSpace objects, 0(0B) LOS objects, 15% free, 22MB/26MB, paused 1.494ms total 103.556ms
10-11 17:32:01.099 3553-3572/com.mypackage I/art: Background sticky concurrent mark sweep GC freed 37651(3MB) AllocSpace objects, 0(0B) LOS objects, 7% free, 23MB/25MB, paused 6.855ms total 39.761ms
10-11 17:32:50.283 3553-3553/com.mypackage V/InputMethodManager: onWindowFocus: android.support.v7.widget.RecyclerView{119be94e VFED.... .F...... 0,0-600,854 #7f090150 app:id/recycler_view} softInputMode=16 first=false flags=#81810100
10-11 17:33:15.775 3553-3572/com.mypackage I/art: Background partial concurrent mark sweep GC freed 37311(2MB) AllocSpace objects, 0(0B) LOS objects, 15% free, 22MB/26MB, paused 1.446ms total 101.032ms
10-11 17:33:22.139 3553-9897/com.mypackage D/OpenGLRenderer: DisplayEventReceiver 0xb0615050 requestNextVsync
10-11 17:33:22.153 3553-9897/com.mypackage D/OpenGLRenderer: DisplayEventReceiver 0xb0615050 latestVsyncEvent 7668096397615
10-11 17:33:40.051 3553-9897/com.mypackage D/OpenGLRenderer: DisplayEventReceiver 0xb0615050 requestNextVsync
10-11 17:33:40.056 3553-9897/com.mypackage D/OpenGLRenderer: DisplayEventReceiver 0xb0615050 latestVsyncEvent 7685998917119
10-11 17:33:57.871 3553-3572/com.mypackage I/art: Background partial concurrent mark sweep GC freed 36892(2MB) AllocSpace objects, 0(0B) LOS objects, 15% free, 22MB/26MB, paused 1.661ms total 109.571ms
10-11 17:34:11.621 3553-3572/com.mypackage I/art: Background sticky concurrent mark sweep GC freed 37628(3MB) AllocSpace objects, 0(0B) LOS objects, 7% free, 23MB/25MB, paused 6.664ms total 38.293ms
10-11 17:34:43.011 3553-3572/com.mypackage I/art: Background partial concurrent mark sweep GC freed 37327(2MB) AllocSpace objects, 0(0B) LOS objects, 15% free, 22MB/26MB, paused 1.452ms total 106.040ms
10-11 17:35:27.299 3553-3572/com.mypackage I/art: Background partial concurrent mark sweep GC freed 37212(2MB) AllocSpace objects, 0(0B) LOS objects, 15% free, 22MB/26MB, paused 1.420ms total 108.233ms