0

I have an IntentService in my background that already started and running. Now I want to resuming this service from my activity, Any ideas?

iSun
  • 1,714
  • 6
  • 28
  • 57
  • you can see intent service lifecycle if that possible to resume i dont think so – DjHacktorReborn Mar 08 '13 at 14:00
  • @DjHacktorReborn Already saw, but did not find anything! – iSun Mar 08 '13 at 14:02
  • Can you describe in more detail what you mean? An `IntentService` is, by design, not intended to keep "running". It is run on a single Thread for as long as the Intent handling takes. After that, it is not exactly _running_, more _waiting_. So what would _resume_ mean in this context? – class stacker Mar 08 '13 at 14:05
  • @ClassStacker So if I want to keep running my `IntentService` what should I do? Should I change it to `Service` or not? If I want to say more clearly I want to make an android download manager and keep downloading in background according to this [link](http://stackoverflow.com/questions/3028306/download-a-file-with-android-and-showing-the-progress-in-a-progressdialog). But after pause my android activity I lost the UI and that's while my service is running but I can't use it to update my UI through `ResultReviver`. – iSun Mar 08 '13 at 14:18
  • Sounds like you have a different problem then, because no matter whether or not it's an IntentService, you will need to re-attach to it. Neither Service nor IntentService do this by themselves. So you don't want to _resume_ it, you want to _re-attach_ to it. – class stacker Mar 08 '13 at 14:23
  • @ClassStacker yup this is exactly what I want, How can I re-attach it? – iSun Mar 08 '13 at 14:28
  • Does it run in a different process as the Activity, in other words, do you use the `android:process` attribute in the manifest? – class stacker Mar 08 '13 at 14:29
  • @ClassStacker I didn't using `android:process` attribute in the manifest. – iSun Mar 08 '13 at 14:30
  • @iSun I am a bit curious, if you send an Intent to an IntentService, then it will do what you ask for, then if you want to do it again you can send a new Intent. Does this not work for you? – Simon Zettervall Mar 08 '13 at 14:34
  • I suggest that you use the search engine of your choice once more now that you have understood that you do not want to "resume" your IntentService. – class stacker Mar 08 '13 at 14:50

1 Answers1

0

As per the Android Developer Site it is not possible.

This is a subclass of Service that uses a worker thread to handle all start requests, one at a time. This is the best option if you don't require that your service handle multiple requests simultaneously. All you need to do is implement onHandleIntent(), which receives the intent for each start request so you can do the background work.

For making download manger have the IntentService notify something (e.g., via a Messenger) about the failed download, so you can enqueue that file sometime later once Internet access returns

DjHacktorReborn
  • 2,908
  • 2
  • 20
  • 29