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
5
votes
4 answers

Why am I getting getApplicationcontext() null?

I'm not sure whats wrong in it! I read here that Intentservice is itself a subclass of Context. public class GCMNotificationIntentService extends IntentService { private NotificationManager mNotificationManager; NotificationCompat.Builder…
5
votes
1 answer

java.lang.ClassCastException: android.os.ResultReceiver cannot be cast to com.hello.utils.network.MyReciever

i am trying to use a custom ResultReciever from an intent into a intentService but i get this bizare error. any ideas why? Followed this guide in using resulReciever as…
Jono
  • 17,341
  • 48
  • 135
  • 217
5
votes
3 answers

How to download multiple files concurrently using intentservice in Android?

I want to create a service similar to this one, (reference from Here), to download multiple files asynchronously in Android. public static class DownloadingService extends IntentService { public static String PROGRESS_UPDATE_ACTION =…
5
votes
1 answer

START_STICKY for IntentService

I have seen many android Service examples where return START_STICKY is used to start an app on boot but is there anyway I can use the same for IntentService. I understand that Service method runs on the main UI thread and the IntentService as a…
5
votes
5 answers

Problems in Calling AsyncTask from IntentService

I have created IntentService class and performing asyncTask but getting exception when onPreExecute() is called at this code line pDialog.show(); AsyncHandlerService Class --- public class AsyncHandlerService extends IntentService{ ProgressDialog…
sjain
  • 23,126
  • 28
  • 107
  • 185
4
votes
2 answers

Cannot do work in background periodically with alarmmanager

I want to call a service in background by the hour. first problem is alarm manager is not working smoothly. Timer is terrible, sometimes early sometimes later. second problem is, RemoteServiceException : Context.startForegroundService() did not…
4
votes
1 answer

How convert Bundle to WorkManager Data

I try to get rid of IntentService when handle GCM as described here. Because of Android O background limitation. But i can't pass Bundle extras with push info as parameter to WorkManager from BroadcastReceiver. Is there any way to put Bundle into…
4
votes
2 answers

Android JobIntentService - onStartCommand vs onHandleWork

I'm currently extending from Service class for my customized service implementation. As part of Android-O migration, I want to use JobIntentService. Currenlty all my logic is in service's onStartCommand method. However, as per JobIntentService I…
4
votes
1 answer

IntentService or JobScheduler to perform I/O intensive data save operation during onPause

Currently, during Activity onPause(), I'm performing I/O operations, to persist application data into disk. private void save() { saveDataToFiles(); } public void onPause() { super.onPause(); save() } As time goes on, the application…
4
votes
1 answer

Oreo, default SMS App and ACTION_RESPOND_VIA_MESSAGE

Applications targeting Android O have a couple of new rules when using services, one of them is that we can't start services while the application is in background. One of the requirements to be a default SMS application is: (from the Telephony.java…
4
votes
4 answers

Android GPS Location Periodically

I want to create an App which fetch user's location in every 5 min between 9:00 AM to 9:00 PM. Now i am not able to think the flow. I am confused on: Should i implement 2 repeating alarm managers , one for every 5 min and another one for time slot.…
4
votes
1 answer

Android Intent Service work requests running parallely

I have created an IntentService as follows: public class OrdersSyncService extends IntentService { private static final String TAG = OrdersSyncService.class.getSimpleName(); private Order orderObject; public OrdersSyncService()…
Vicky
  • 1,807
  • 5
  • 23
  • 34
4
votes
3 answers

Should I use Service or IntentService?

I have to create two android apps. App1 - takes an input message (i.e. “Hello World”) from the user and App2 prints out the message to the Console viewable via ADB Logcat.  The message from App1 should be sent to App2 via Intents.  App2 should be a…
4
votes
2 answers

Broadcast Receiver in an IntentService

I am trying to register the DownloadManager.ACTION_DOWNLOAD_COMPLETE receiver in onHandleIntent() method of my IntentService and unregistering the receiver in onDestroy() method of the IntentService. But I think its not getting registered, since the…
4
votes
4 answers

OnHandleIntent() not called in IntentService

I know this question has been asked before, but I've been over all of the answers I could find and still haven't been able to solve the problem. The issue is that when by BroadcastReceiver starts the IntentService onHandleIntent() isn't called.…