views:

35

answers:

2

Is it possible, with an IntentService, to send another intent to the IntentService from within the IntentService?

For example, say my IntentService is processing an Intent which has it write a bunch of data to the database. During this time, several other Intents to write other data may [or may not] have been queued up in the IntentService. Suppose, after processing that Intent by writing the data to the application's database, I want to queue up another Intent to send that data via web service to "the cloud." Perhaps I want to queue this processing in another Intent because sending to the cloud is secondary.

Is it possible? Would it cause any problems if the Intent being processed is the only Intent in the queue at the time the IntentService is trying to queue another Intent?

+1  A: 

I am not aware of any problems here. Internally, IntentService just uses its own thread, Looper, and Handler for the queuing work.

CommonsWare
So how would I post that new Intent to the IntentService? From an Activity, I just call startService. Can I call startService from within the IntentService?
Andrew
@Andrew: I don't see why not. `startService()` is a method on `Context`, so it is available to you in `IntentService`.
CommonsWare
Ok, I'll give it a shot. Thank you
Andrew
A: 

I've tested this out and it seems to be a bad idea. My first Intent is being processed over and over and over and over indefinitely

Andrew