Skip to content
This repository has been archived by the owner on Mar 18, 2024. It is now read-only.

Commit

Permalink
Fix crash in android s
Browse files Browse the repository at this point in the history
  • Loading branch information
AnkitSuda committed Dec 28, 2022
1 parent d0d236c commit 7ea9869
Showing 1 changed file with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import android.app.NotificationManager
import android.app.PendingIntent
import android.content.Context
import android.content.Intent
import android.os.Build
import android.os.Vibrator
import androidx.core.app.NotificationCompat
import com.ankitsuda.rebound.coreRestTimer.R
Expand All @@ -37,6 +38,13 @@ import dagger.hilt.android.scopes.ServiceScoped
@InstallIn(ServiceComponent::class)
object RestTimerModule {

private val flags =
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE
} else {
PendingIntent.FLAG_UPDATE_CURRENT
}

@ClickPendingIntent
@ServiceScoped
@Provides
Expand All @@ -46,7 +54,7 @@ object RestTimerModule {
app,
0,
app.packageManager.getLaunchIntentForPackage(app.packageName),
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_MUTABLE
flags
)

@CancelActionPendingIntent
Expand All @@ -60,7 +68,7 @@ object RestTimerModule {
Intent(app, RestTimerService::class.java).also {
it.action = ACTION_CANCEL
},
PendingIntent.FLAG_UPDATE_CURRENT
flags
)


Expand All @@ -75,7 +83,7 @@ object RestTimerModule {
Intent(app, RestTimerService::class.java).also {
it.action = ACTION_RESUME
},
PendingIntent.FLAG_UPDATE_CURRENT
flags
)


Expand All @@ -90,7 +98,7 @@ object RestTimerModule {
Intent(app, RestTimerService::class.java).also {
it.action = ACTION_PAUSE
},
PendingIntent.FLAG_UPDATE_CURRENT
flags
)


Expand Down

0 comments on commit 7ea9869

Please sign in to comment.