24.03.2012 16:45, Put_tiMe пишет:
Will they be invoked one after the other, in the order they were raised.

As Mark already said, yes, it's sequential.

If you look at the implementation:

https://github.com/android/platform_frameworks_base/blob/master/core/java/android/app/IntentService.java

... it's really simple, and uses HandlerThread, which is a small helper class that creates a thread which sits in a loop processing messages one by one.

Is there any chance that 'onHandleIntent' will be called in parallel, to handle more than one intent simultaneously.

If that's what you want, you could very easily implement this:

- Either by using ThreadPoolExecutor:

http://developer.android.com/reference/java/util/concurrent/ThreadPoolExecutor.html

- Or by using AsyncTask.

Note that starting with Android 4.0 you'd need to use task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR) if parallel execution is desired.

- Or in some other way....

The important thing (besides posting work to another thread or a pool of threads) is to manage the service's lifetime by calling stopSelf(startId), where startId is the value from the service's onStrartCommand that corresponds to the Intent you just finished processing.

--
Kostya Vasilyev

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to