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
2
votes
1 answer

Perform background scheduled repeating task in Android, and differences between IntentService and Runnable

I am an iOS developer and recently started Android development. Currently I need the application to perform a repeating check regarding a remote resource (a JSON file) in the background, which I would like to: App finished launching Initiate…
2
votes
0 answers

Unit-Test / Integration-Test: Was startService() called

In this question some years ago someone suggested unit-testing a startService call by using a specific Context. Now, about 4 years later, I am wondering if this functionality can't be handled by some Framework like Espresso. I have an…
2
votes
0 answers

How to show loading animation while my activity does others functions?

I have an activity which calls functions which have Thread.Sleep calls and Handlers which do further processing of data i receive from a Bluetooth connection. I want to show a loading progress bar animation while the handlers are being called. It…
2
votes
1 answer

Update ui from service without broadcast receiver

In my app I have used IntentService and in it I call a webservice and parse my response. After my parsing is done I want to update the UI. I saw that there is a way to update UI using broadcast receiver but is there any other way to update UI if I…
2
votes
1 answer

Android Run Process in Background

I am making an application that uses a BroadcastReceiver and a WakefulServiceIntent to call a method in my application every 10 minutes. The problem is, sometimes it calls it, sometimes it doesn't. I need to call this method every 10 minutes, even…
2
votes
2 answers

How to receive values from an IntentService in another IntentService?

I have this IntentService (HttpService) which fetches raw json data from a webservice: public class HttpService extends IntentService { public static final String BROADCAST_ACTION = "com.example.HttpService"; public HttpService() { …
2
votes
0 answers

Is it possible to start an IntentService from another Service

This is unique question in a sense that I am passing stringExtra to start the IntentService as opposed to the question that simply starts a service from within a service(my question is labeled as possible duplicate of). I am trying to start…
The_Martian
  • 3,684
  • 5
  • 33
  • 61
2
votes
2 answers

how to wait the volley response to finish it's work inside intentservice?

Working with intentservice to get the data of 7 Rss Feed links with using " Google Volley " in the background and use ResultReceiver to get the result , But I can't configure how to wait on the volley response to finish it's job to fire flag with …
2
votes
1 answer

RequestLocationUpdates with PendingIntent never fires

I'm trying to run a location check every so often in the background, so I'm trying to use a IntentService to get location updates from the FusedLocationApi. But the PendingIntent never fires. Code: public class LocationIntentService extends…
2
votes
2 answers

SecurityException: Permission Denial: starting Intent { act=android.intent.action.MAIN cat=[android.intent.category.HOME]

In my app when user press back the app is minimised. This is the onBackPressed() method @Override public void onBackPressed() { Intent i = new Intent(); i.setAction(Intent.ACTION_MAIN); i.addCategory(Intent.CATEGORY_HOME); …
Biswajit
  • 1,829
  • 1
  • 18
  • 33
2
votes
3 answers

Stop service in an activity

I'm using following code to stop my service Intent intent = new Intent(MainActivity.this, UsageRecorderService.class); stopService(intent); And this is my service that works indefinitely public class UsageRecorderService extends IntentService { …
Mousa Jafari
  • 677
  • 1
  • 6
  • 21
2
votes
1 answer

is it posible to use locationManager in a non-activity class

am trying to create a class that will be used in acquiring the users Location. this class will be utilized by an IntentService in the background. is there a way to do this without extending Activity or FragmentActivity in my class. the code so far…
hyena
  • 755
  • 1
  • 14
  • 24
2
votes
1 answer

Can multiple Android IntentServices run at the same time?

From what I understand, an IntentService can only handle one Intent at a time as it shares a worker thread to do all of its work. But if I have multiple IntentServices in my app, can they run in parallel, or do they all share the single worker…
Karim Varela
  • 7,562
  • 10
  • 53
  • 78
2
votes
0 answers

How to Start Activity from IntentService and passing the Class from another class?

I want to start an activity through IntentService, but the catch is the activty name or the class name will be passed as parameter to the IntentService. Following are my code blocks... public class Runner { Context context; public…
2
votes
2 answers

Android: Design for concurrent background jobs (Service, IntentService or AsyncTask?)

I need help designing a solution to a problem specific to long running background tasks. Background: I have an app with activity that displays a list of files. The files can each be downloaded. Each downloaded file can have an update. The updates,…