Skip to content

Commit b0bc871

Browse files
committed
Add MODE_BACKGROUND_ACTIVITY_START_ALLOWED option
1 parent e7d9831 commit b0bc871

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

android/src/main/kotlin/es/antonborri/home_widget/HomeWidgetIntent.kt

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package es.antonborri.home_widget
22

33
import android.app.Activity
4+
import android.app.ActivityOptions
45
import android.app.PendingIntent
56
import android.content.Context
67
import android.content.Intent
@@ -21,7 +22,14 @@ object HomeWidgetLaunchIntent {
2122
flags = flags or PendingIntent.FLAG_IMMUTABLE
2223
}
2324

24-
return PendingIntent.getActivity(context, 0, intent, flags)
25+
if (Build.VERSION.SDK_INT < 34) {
26+
return PendingIntent.getActivity(context, 0, intent, flags)
27+
}
28+
29+
val options = ActivityOptions.makeBasic()
30+
options.pendingIntentBackgroundActivityStartMode = ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_ALLOWED
31+
32+
return PendingIntent.getActivity(context, 0, intent, flags, options.toBundle())
2533
}
2634
}
2735

0 commit comments

Comments
 (0)