diff --git a/.idea/caches/build_file_checksums.ser b/.idea/caches/build_file_checksums.ser index 55b326c..82a69c2 100644 Binary files a/.idea/caches/build_file_checksums.ser and b/.idea/caches/build_file_checksums.ser differ diff --git a/app/build.gradle b/app/build.gradle index 0fe4eaf..0ac4059 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -23,7 +23,7 @@ android { applicationId "com.tommasoberlose.anotherwidget" minSdkVersion 23 targetSdkVersion 30 - versionCode 112 + versionCode 114 versionName "2.1.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" diff --git a/app/release/app-release.aab b/app/release/app-release.aab index 2dc251a..d898a49 100644 Binary files a/app/release/app-release.aab and b/app/release/app-release.aab differ diff --git a/app/src/main/java/com/tommasoberlose/anotherwidget/services/LocationService.kt b/app/src/main/java/com/tommasoberlose/anotherwidget/services/LocationService.kt index 3281f6d..529e44a 100644 --- a/app/src/main/java/com/tommasoberlose/anotherwidget/services/LocationService.kt +++ b/app/src/main/java/com/tommasoberlose/anotherwidget/services/LocationService.kt @@ -30,13 +30,15 @@ class LocationService : Service() { override fun onCreate() { super.onCreate() + startForeground(LOCATION_ACCESS_NOTIFICATION_ID, getLocationAccessNotification()) + } + override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int { if (ActivityCompat.checkSelfPermission( this, Manifest.permission.ACCESS_FINE_LOCATION ) == PackageManager.PERMISSION_GRANTED ) { - startForeground(LOCATION_ACCESS_NOTIFICATION_ID, getLocationAccessNotification()) jobs += GlobalScope.launch(Dispatchers.IO) { LocationServices.getFusedLocationProviderClient(this@LocationService).lastLocation.addOnCompleteListener { task -> @@ -51,7 +53,7 @@ class LocationService : Service() { CoroutineScope(Dispatchers.IO).launch { networkApi.updateWeather() withContext(Dispatchers.Main) { - stopForeground(true) + stopSelf() } } EventBus.getDefault().post(MainFragment.UpdateUiMessageEvent()) @@ -59,7 +61,7 @@ class LocationService : Service() { CoroutineScope(Dispatchers.IO).launch { networkApi.updateWeather() withContext(Dispatchers.Main) { - stopForeground(true) + stopSelf() } } EventBus.getDefault().post(MainFragment.UpdateUiMessageEvent()) @@ -67,8 +69,9 @@ class LocationService : Service() { } } } else { - stopForeground(true) + stopSelf() } + return START_STICKY } override fun onDestroy() {