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.

1116 questions
116
votes
7 answers

Android - Start service on boot

From everything I've seen on Stack Exchange and elsewhere, I have everything set up correctly to start an IntentService when Android OS boots. Unfortunately it is not starting on boot, and I'm not getting any errors. Maybe the experts can…
Gady
  • 4,595
  • 7
  • 33
  • 46
84
votes
7 answers

Android: keep Service running when app is killed

I want to keep a IntentService running in background even when the app is killed. And by "killed" I mean press home-button for a long time -> see all running apps -> swipe my app aside -> app killed OR press back-button for a long time -> app…
user2078872
  • 1,147
  • 2
  • 10
  • 15
54
votes
8 answers

Should I use AsyncTask or IntentService for my application?

I have been reading around on internet connectivity with Android and noticed there are different ways to handle this i.e. AsyncTask and IntentService. However, I'm still not sure which one to use. My application is basically a location/trails finder…
Johnathan Au
  • 5,061
  • 17
  • 61
  • 120
48
votes
6 answers

REST API Client Library for Android

We are building a location based messaging app which uses Parse.com as back-end (Parse.com is similar to Urban Airship/PubNub, etc) and we now want to switch to our own back-end for better control. For this, we have built a node.js based back-end…
Madhur
  • 1,971
  • 1
  • 21
  • 29
47
votes
5 answers

How to get Context in an Intent Service

Here's the scenario: I have a WakefulBroadcastReceiver that does a backup to a network computer or the cloud. It's set to go off in the middle of the night, when I know the tablet will have access to the LAN. The backup will store the data to a…
user4612159
  • 471
  • 1
  • 4
  • 4
47
votes
9 answers

How to force an IntentService to stop immediately with a cancel button from an Activity?

I have an IntentService that is started from an Activity and I would like to be able to stop the service immediately from the activity with a "cancel" button in the activity. As soon as that "cancel" button is pressed, I want the service to stop…
pvans
  • 987
  • 2
  • 9
  • 15
43
votes
1 answer

Android Work Manager vs Services?

In my Android app i have multiple intent services which run one after another and the very first intent service is trigerred by a broadcast. I came across Work Manager a few days ago and really liked the simplicity of the Worker and the WorkManager…
Dishonered
  • 6,544
  • 7
  • 23
  • 43
35
votes
2 answers

How is an Intent Service Declared in the Android Manifest?

Straight forward question: Is an IntentService declared in the Android Manifest as a regular service, or is there another way? It tried searching for it, but I couldn't find the answer. Here is the regular Service declaration:
gtdevel
  • 1,483
  • 5
  • 21
  • 36
35
votes
4 answers

When to unregister BroadcastReceiver? In onPause(), onDestroy(), or onStop()?

When should I use unregisterReceiver? In onPause(), onDestroy(), or onStop()? Note: I need the service to run in the background. Update: I get an exception releasing receivers null. Activity has leaked intent receivers are you missing call to…
Muhammad
  • 516
  • 1
  • 5
  • 20
29
votes
4 answers

IntentService won't show Toast

This IntentService I created will show Toasts in onStartCommand() and in onDestroy(), but not in onHandleIntent(). Am I missing something about the limitations of an IntentService? public class MyService extends IntentService { private static…
Tenfour04
  • 39,254
  • 8
  • 47
  • 96
28
votes
6 answers

Waiting for asynchronous callback in Android's IntentService

I have an IntentService that starts an asynchronous task in another class and should then be waiting for the result. The problem is that the IntentService will finish as soon as the onHandleIntent(...) method has finished running, right? That means,…
caw
  • 29,212
  • 58
  • 168
  • 279
28
votes
10 answers

Android: Using WebView outside an Activity context

I am trying to achieve Web Scraping through a background IntentService that periodically scrape a website without a view displaying on the users phone. Since I have to do call some javascript on the loaded page I cannot use any HttpGet's etc. I…
28
votes
1 answer

Notification created by IntentService uses always a wrong Intent

Problem When the user presses Send "Button 1"(scroll down to see the construction of the app) a new Notification is created from the RefreshService. If the user presses this notification a MainActivity instance gets started and receives a String…
25
votes
1 answer

Android how to check if the intent service is still running or has stopped running

I need to know if all intentservices in the queue are "consumed" or the other way is to find out if it is still doing something so that I don't continue until all services have stopped running. Any ideas?
Maurice
  • 6,273
  • 13
  • 49
  • 75
25
votes
3 answers

How to create toast from IntentService? It gets stuck on the screen

I'm trying to have my IntentService show a Toast message, but when sending it from the onHandleIntent message, the toast shows but gets stuck and the screen and never leaved. I'm guessing its because the onHandleIntent method does not happen on the…
Omri
  • 1,097
  • 1
  • 11
  • 22
1
2 3
74 75