diff --git a/core/java/android/app/Service.java b/core/java/android/app/Service.java index 0ab3f2f4be463..7cb1d89aa9543 100644 --- a/core/java/android/app/Service.java +++ b/core/java/android/app/Service.java @@ -697,6 +697,18 @@ public abstract class Service extends ContextWrapper implements ComponentCallbac * service element of manifest file. The value of attribute * {@link android.R.attr#foregroundServiceType} can be multiple flags ORed together.
* + *Note: + * Beginning with SDK Version {@link android.os.Build.VERSION_CODES#S}, + * apps targeting SDK Version {@link android.os.Build.VERSION_CODES#S} + * or higher are not allowed to start foreground services from the background. + * See + * + * Behavior changes: Apps targeting Android 12 + * + * for more details. + *
Note: + * Beginning with SDK Version {@link android.os.Build.VERSION_CODES#S}, + * apps targeting SDK Version {@link android.os.Build.VERSION_CODES#S} + * or higher are not allowed to start foreground services from the background. + * See + * + * Behavior changes: Apps targeting Android 12 + * + * for more details. + *
This function will throw {@link SecurityException} if you do not * have permission to start the given service. * - *
Note: Each call to startService() + *
Note: Each call to startService() * results in significant work done by the system to manage service * lifecycle surrounding the processing of the intent, which can take * multiple milliseconds of CPU time. Due to this cost, startService() @@ -3191,6 +3192,25 @@ public abstract class Context { * for high frequency calls. *
* + * Beginning with SDK Version {@link android.os.Build.VERSION_CODES#O}, + * apps targeting SDK Version {@link android.os.Build.VERSION_CODES#O} + * or higher are not allowed to start background services from the background. + * See + * + * Background Execution Limits + * for more details. + * + *Note: + * Beginning with SDK Version {@link android.os.Build.VERSION_CODES#S}, + * apps targeting SDK Version {@link android.os.Build.VERSION_CODES#S} + * or higher are not allowed to start foreground services from the background. + * See + * + * Behavior changes: Apps targeting Android 12 + * + * for more details. + *
Note: + * Beginning with SDK Version {@link android.os.Build.VERSION_CODES#S}, + * apps targeting SDK Version {@link android.os.Build.VERSION_CODES#S} + * or higher are not allowed to start foreground services from the background. + * See + * + * Behavior changes: Apps targeting Android 12 + * + * for more details. + *