This commit is contained in:
Tommaso Berlose 2021-01-14 14:14:00 +01:00
parent 6ea40a51fe
commit cce86a970c
3 changed files with 4 additions and 12 deletions

View File

@ -57,8 +57,6 @@ class UpdatesReceiver : BroadcastReceiver() {
} }
Actions.ACTION_REFRESH -> { Actions.ACTION_REFRESH -> {
ActiveNotificationsHelper.clearLastNotification(context)
GlobalScope.launch(Dispatchers.IO) { GlobalScope.launch(Dispatchers.IO) {
CalendarHelper.updateEventList(context) CalendarHelper.updateEventList(context)
MediaPlayerHelper.updatePlayingMediaInfo(context) MediaPlayerHelper.updatePlayingMediaInfo(context)

View File

@ -34,6 +34,7 @@ class LocationService : Service() {
} }
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int { override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
startForeground(LOCATION_ACCESS_NOTIFICATION_ID, getLocationAccessNotification())
job?.cancel() job?.cancel()
job = GlobalScope.launch(Dispatchers.IO) { job = GlobalScope.launch(Dispatchers.IO) {
if (ActivityCompat.checkSelfPermission( if (ActivityCompat.checkSelfPermission(
@ -85,11 +86,7 @@ class LocationService : Service() {
@JvmStatic @JvmStatic
fun requestNewLocation(context: Context) { fun requestNewLocation(context: Context) {
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) { ContextCompat.startForegroundService(context, Intent(context, LocationService::class.java))
context.startForegroundService(Intent(context, LocationService::class.java))
} else {
context.startService(Intent(context, LocationService::class.java))
}
} }
} }

View File

@ -35,11 +35,7 @@ class UpdateCalendarService : Service() {
companion object { companion object {
const val CALENDAR_SYNC_NOTIFICATION_ID = 28468 const val CALENDAR_SYNC_NOTIFICATION_ID = 28468
fun enqueueWork(context: Context) { fun enqueueWork(context: Context) {
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) { ContextCompat.startForegroundService(context, Intent(context, UpdateCalendarService::class.java))
context.startForegroundService(Intent(context, UpdateCalendarService::class.java))
} else {
context.startService(Intent(context, UpdateCalendarService::class.java))
}
} }
} }
@ -55,6 +51,7 @@ class UpdateCalendarService : Service() {
} }
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int { override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
startForeground(CALENDAR_SYNC_NOTIFICATION_ID, getCalendarSyncNotification())
job?.cancel() job?.cancel()
job = GlobalScope.launch(Dispatchers.IO) { job = GlobalScope.launch(Dispatchers.IO) {