Skip to content

Commit 4347497

Browse files
committed
feat: Pass ActivityOptions bundle for Android 14 compatibility #301
1 parent 0dd1557 commit 4347497

File tree

1 file changed

+11
-1
lines changed
  • android/src/main/kotlin/com/pravera/flutter_foreground_task/utils

1 file changed

+11
-1
lines changed

android/src/main/kotlin/com/pravera/flutter_foreground_task/utils/PluginUtils.kt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package com.pravera.flutter_foreground_task.utils
33
import android.app.Activity
44
import android.app.ActivityManager
55
import android.app.ActivityManager.RunningAppProcessInfo
6+
import android.app.ActivityOptions
67
import android.app.AlarmManager
78
import android.content.Context
89
import android.content.Intent
@@ -52,7 +53,16 @@ class PluginUtils {
5253
if (route != null) {
5354
launchIntent.putExtra("route", route)
5455
}
55-
context.startActivity(launchIntent)
56+
57+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
58+
val options = ActivityOptions.makeBasic().apply {
59+
pendingIntentBackgroundActivityStartMode =
60+
ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_ALLOWED
61+
}
62+
context.startActivity(launchIntent, options.toBundle())
63+
} else {
64+
context.startActivity(launchIntent)
65+
}
5666
}
5767
}
5868

0 commit comments

Comments
 (0)