Pending intent background options compatibility

pull/214/head
M66B 2 years ago
parent 05eaedac08
commit b27ab6240d

@ -19,6 +19,7 @@ package eu.faircode.email;
Copyright 2018-2024 by Marcel Bokhorst (M66B) Copyright 2018-2024 by Marcel Bokhorst (M66B)
*/ */
import static android.app.ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_ALLOWED;
import static android.os.Process.THREAD_PRIORITY_BACKGROUND; import static android.os.Process.THREAD_PRIORITY_BACKGROUND;
import static androidx.browser.customtabs.CustomTabsService.ACTION_CUSTOM_TABS_CONNECTION; import static androidx.browser.customtabs.CustomTabsService.ACTION_CUSTOM_TABS_CONNECTION;
import static com.google.android.material.textfield.TextInputLayout.END_ICON_NONE; import static com.google.android.material.textfield.TextInputLayout.END_ICON_NONE;
@ -1936,12 +1937,17 @@ public class Helper {
} }
static Bundle getBackgroundActivityOptions() { static Bundle getBackgroundActivityOptions() {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.UPSIDE_DOWN_CAKE) if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU)
return null; return null;
else {
ActivityOptions options = ActivityOptions.makeBasic(); ActivityOptions options = ActivityOptions.makeBasic();
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.TIRAMISU)
options.setPendingIntentBackgroundActivityLaunchAllowed(true); options.setPendingIntentBackgroundActivityLaunchAllowed(true);
else
options.setPendingIntentBackgroundActivityStartMode(MODE_BACKGROUND_ACTIVITY_START_ALLOWED);
return options.toBundle(); return options.toBundle();
} }
}
static Fragment recreateFragment(Fragment fragment, FragmentManager fm) { static Fragment recreateFragment(Fragment fragment, FragmentManager fm) {
try { try {

Loading…
Cancel
Save