From 1e3535276365da64ad066bffc86238ed04a7ae13 Mon Sep 17 00:00:00 2001 From: Chris Craik Date: Mon, 18 Apr 2016 10:20:50 -0700 Subject: [PATCH] Document startService cost bug:27998068 Change-Id: Iab66c21856a08678e29a1e5cf26a5f71a22027da --- core/java/android/content/Context.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/core/java/android/content/Context.java b/core/java/android/content/Context.java index 15cc17da21500..8349d3da68608 100644 --- a/core/java/android/content/Context.java +++ b/core/java/android/content/Context.java @@ -2446,6 +2446,15 @@ public abstract class Context { *

This function will throw {@link SecurityException} if you do not * have permission to start the given service. * + *

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() + * should not be used for frequent intent delivery to a service, and only + * for scheduling significant work. Use {@link #bindService bound services} + * for high frequency calls. + *

+ * * @param service Identifies the service to be started. The Intent must be either * fully explicit (supplying a component name) or specify a specific package * name it is targetted to. Additional values