Questions tagged [android-intentservice]

The IntentService class provides a straightforward structure for running an operation on a single background thread.

The IntentService class provides a straightforward structure for running an operation on a single background thread. This allows it to handle long-running operations without affecting your user interface's responsiveness. Also, an IntentService isn't affected by most user interface lifecycle events, so it continues to run in circumstances that would shut down an AsyncTask

An IntentService has a few limitations:

  • It can't interact directly with your user interface. To put its results in the UI, you have to send them to an Activity.
  • Work requests run sequentially. If an operation is running in an IntentService, and you send it another request, the request waits until the first operation is finished.
  • An operation running on an IntentService can't be interrupted.

However, in most cases an IntentService is the preferred way to simple background operations.

461 questions
3
votes
0 answers

Background service using alarm manager

I have followed below example code for implementing Periodic background service. Periodic task executes correctly If app on foreground on 1st time. If, I close application then Background service is not working.…
3
votes
1 answer

Service vs IntentService in a case of location tracking service

I read about the differences between Service and IntentService. The main thing I read is that IntentService has a Workerhtread that the service runs in. I need to have a service which run regardless of the application activities/ui, and keeps track…
3
votes
1 answer

How to read SMS code from your android App

We are looking to build the functionality in our app to read a security code that being sent as part of SMS and display on the textView. Also, I am not looking to build a broadcast receiver, may be an intent service which only will start run on a…
Bulu
  • 1,351
  • 3
  • 16
  • 37
3
votes
2 answers

Do separate IntentService instances share the same queue?

I have a question regarding IntentService Let's say I have two intent service classes that do separate tasks unrelated to each other. public class TaskA extends IntentService{ @Override protected void onHandleIntent(Intent workIntent) {} …
Ersen Osman
  • 7,067
  • 8
  • 47
  • 80
3
votes
0 answers

Notification of android foreground intent service not always removed

In my app uPod I have several intent services performing one shot tasks like downloading episodes or synchronizing episode states. I run these tasks as foreground services with a notification shown in Android's status bar. From time to time, when…
3
votes
0 answers

Connecting to Google Api Client - why?

I'm building a location based app and want to use the Displaying a Location Address instructions. I saw that I need to connect to Google Api Client but I don't know 1) why, or 2) what the benefit of using this google api connection for fetching an…
Nir B
  • 75
  • 2
  • 6
3
votes
1 answer

Android - Access SharedPreferences once application is stopped/destroyed

I implementing notifications together with a periodical alarm and on IntentService i need to validate some values on SharedPreferences to decide if I will show a notifications or not. When the application is on pause i have context, and everything…
Bugdr0id
  • 2,962
  • 6
  • 35
  • 59
3
votes
2 answers

Android Handle IntentService onStop event

I want to handle IntentService onStop event. IntentService will receive the Intents, launch a worker thread, and stop the service as appropriate but I have not found onStop method. It has onDestroy() but actually onDestroy() method can not be…
sytolk
  • 7,223
  • 3
  • 25
  • 38
3
votes
1 answer

Scheduling recursive handlers from an IntentService for retrying http calls

I am trying to implement exponential backoff for retrying failed http calls by scheduling a thread with handler.postDelayed(...) every time my request fail. The problem is that I am doing this from an IntentService which dies after scheduling the…
3
votes
3 answers

how to wake up my intent service every 5 minutes

I know this question is asked before, but I didn't get any answer, I want to create an intent service that run a thread all the time, but when I get out from the app my service is stopped then the thread stopped too. I need to create something to…
Malo
  • 1,232
  • 2
  • 17
  • 28
3
votes
1 answer

IntentService doesn't get called in combination with PendingIntent

I am trying to make an Android app about Geofencing. I have followed the tutorial on developers page and the sample code, however it doesn't work as expected. I could have maybe made some failures regarding the life cycle of an Android app since I…
3
votes
1 answer

ResultReceiver gives Nullpointer exception

I am using Geocoding to retrieve addresses of latitude,longitude values. I'm implementing this GeoCoding in a seperate class extending IntentService. When I retrieve the address I want to send it back to the original main activity, and for this i…
alperc
  • 373
  • 2
  • 18
3
votes
1 answer

Service OR IntentService playing audio after recording

I want to achieve following goals: Record Audio Send Audio to Server Play Audio I know that First 2 tasks are possible by Using Service as I've done that in one of the previous apps but when it comes to playing an audio file, it needs to be…
GAMA
  • 5,958
  • 14
  • 79
  • 126
3
votes
3 answers

GcmBroadcastReceiver / GcmIntentService dies

I'm using GCM to get notified when an image is posted, and then I download and process it: public class GcmBroadcastReceiver extends WakefulBroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { …
3
votes
2 answers

My app closes because of device low memory

I am developing an app that uses intent services to backup some files. The app works fine and does not crash. However, when I start an app in background the app will close sometimes when it runs for two days or sometimes in one night only. Is it…
Bhanu Sharma
  • 5,135
  • 2
  • 24
  • 49