Questions tagged [intentservice]

IntentService is a special implementation of Android service component.

IntentService is a special implementation of Android service component that handles asynchronous requests (expressed as Intents) on demand, one at a time. The service is started when Intent is received, handles each Intent in turn using a worker thread, and stops itself when it runs out of work.

All requests are handled on a single worker thread -- they may take as long as necessary (and will not block the application's main loop), but only one request will be processed at a time.

1118 questions
24
votes
1 answer

What is the difference between service, intentService in android?

What is the difference between Service and an IntentService in Android? What is the difference between AsyncTask and an IntentService in Android?
22
votes
2 answers

How to keep an IntentService running even when app is closed?

In my Android app I start an IntentService from within an Activity by calling startService(new Intent(this, MyService.class)); And it works like a charm. I can move between Activies, press the Home button to switch to other apps... and it's still…
fergaral
  • 2,077
  • 6
  • 17
  • 34
21
votes
1 answer

Make a REST API call from an IntentService or an AsyncTask?

Imagine a typical scenario where an activity opens, needs to call a REST HTTP API to get some content, and once received updates the UI. Obviously the API call needs doing on a separate thread, but should it be done using AsyncTask, an…
Ollie C
  • 28,313
  • 34
  • 134
  • 217
20
votes
1 answer

send intent from service to activity

I'm trying to return the result from an IntentSerivce to the mainactivity using an intent, but I can't get it to work. The IntentService receives the intent from the activity without a problem, does it's thing and gets a JSONstring. Now the only…
Pewter
  • 303
  • 1
  • 2
  • 6
20
votes
2 answers

Proper way to stop IntentService

I'm using an IntentService to upload images to a server. My problem is that I don't know how/when to stop the service. When I call stopself() in onHandleIntent(Intent ..) all Intents which are waiting in the IntentService queue are removed. But I…
malinjir
  • 1,475
  • 2
  • 12
  • 17
19
votes
1 answer

tap for more information or stop the app

i create service and custom notification any thing work fine but android said app is running on notification tap for more information or to stop the app. how can i fix this. my custom BroadcastReceiver public class ServiceBootCompleteReciver…
18
votes
4 answers

How to use Notification.deleteIntent

I'm trying to detect when my notification gets cleared. My question directly refers to this answer which outlines what I'm suppose to do. This is how I'm implementing the actions: // usual Notification initialization here notification.deleteIntent =…
Brian
  • 7,955
  • 16
  • 66
  • 107
17
votes
1 answer

Android Service extends ResultReceiver for IntentService, how to implement CREATOR?

My app relies on a Service which stays in sync with external hardware in the background. Because the service operates on the main Thread, it does any heavy work asynchronously using an IntentService. Here is a minimalized example of the code to…
16
votes
4 answers

Can an IntentService run indefinitely?

Based on my understanding, an IntentService will get stopped when its current request is done. Consider the below scenario, i will be triggering a request to the IntentSerivce for every 100ms and the processing time will be 90 ms for that…
Pathy
  • 161
  • 1
  • 3
16
votes
3 answers

Android the difference between onHandleIntent & onStartCommand

I am currently writing a android program which needs an IntentService. When I put the code in the onHandleIntent function, the code does not run, but it doesn't give errors in the MainActivity. But when I copy my code into the onStartCommand, it…
Chromium
  • 517
  • 1
  • 6
  • 21
16
votes
2 answers

Prevent Android "process is bad" error

The process is bad error does not seem to be very well documented, and I have only been able to find workarounds. I am instead interested in the cause of this error and how to prevent it from happening, and not how to manually handle it through…
tep
  • 833
  • 7
  • 13
15
votes
1 answer

Android How to queue multiple intents on an IntentService

I am a little bit confused regarding the usage of IntentService. The documentation says that IntentService queues all intents sent to it and process them one at a time. I took a look at the code of IntentService and I saw that onStartCommand()…
ilomambo
  • 8,290
  • 12
  • 57
  • 106
14
votes
5 answers

Need Help in Downloading in Background Images in Android?

I have an image view , i had written swiping , at that time of swiping,the images are downloading from Internet, so i thought i have to download the images in the background before swiping , for that which i need to use asynctask or Service or…
Sankar Ganesh PMP
  • 11,927
  • 11
  • 57
  • 90
14
votes
1 answer

Robolectric and IntentServices

Using Robolectric, how would one go about testing an IntentService that broadcasts intents as a response? Assuming the following class: class MyService extends IntentService { @Override protected void onHandleIntent(Intent intent) { …
13
votes
2 answers

StartForeground for IntentService

I have an IntentService and I want to make it sticky with an ongoing notification. The problem is that the notification appears and then disappears immediately. The service continues to run. How should I use startForeground() in an…
Matroska
  • 6,885
  • 14
  • 63
  • 99
1
2
3
74 75