summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Brad Fitzpatrick <bradfitz@android.com> 2010-07-27 14:37:02 -0700
committer Brad Fitzpatrick <bradfitz@android.com> 2010-07-27 14:57:08 -0700
commit0166c3530535355e7813f54c4e403a21db94a9d2 (patch)
tree98b0550bd2be366aa013871fd9b8497c1865e087
parent7bcad8a315f12bd6251a998781efac7b11c2ca84 (diff)
Explicitly mention again that startCommand() runs on the main thread.
This is already mentioned at the top of Service.java's javadoc, but I'm seeing people get confused (myself included the other day) after getting used to incoming service stub binder calls being on their own threads and forgetting that startCommand() didn't work that way. Change-Id: Ib79f48d9368ac0ba2d37b7e4dc98d53804bcd59e
-rw-r--r--core/java/android/app/Service.java10
1 files changed, 9 insertions, 1 deletions
diff --git a/core/java/android/app/Service.java b/core/java/android/app/Service.java
index 697a987d5f20..b7a750b6573e 100644
--- a/core/java/android/app/Service.java
+++ b/core/java/android/app/Service.java
@@ -400,7 +400,15 @@ public abstract class Service extends ContextWrapper implements ComponentCallbac
*
* {@sample development/samples/ApiDemos/src/com/example/android/apis/app/ForegroundService.java
* start_compatibility}
- *
+ *
+ * <p class="caution">Note that the system calls this on your
+ * service's main thread. A service's main thread is the same
+ * thread where UI operations place for Activities running in the
+ * same process. You should always avoid stalling the main
+ * thread's event loop. When doing long-running operations,
+ * network calls, or heavy disk I/O, you should kick off a new
+ * thread, or use {@link android.os.AsyncTask}.</p>
+ *
* @param intent The Intent supplied to {@link android.content.Context#startService},
* as given. This may be null if the service is being restarted after
* its process has gone away, and it had previously returned anything