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

How to stop downloading a file using IntentService in android

I am trying to download the file from app server using the IntentService. It is working fine when i want to download the file completely. but I want to cancel the file downloading in the middle of downloading. but it fails. I have tried to stop the…
Umesh Saraswat
  • 560
  • 1
  • 8
  • 22
4
votes
1 answer

How to stop Service when app is paused or destroyed but not when it switches to a new Activity?

Currently I have a Service which I am using to play a sound file in the background whilst the app is open: public class BackgroundSoundService extends Service { MediaPlayer player; public IBinder onBind(Intent arg0) { return null; …
4
votes
1 answer

When IntentService starts does Application object start?

I want to understand Application object lifecycle in Android, especially with IntentService. If IntentService starts, does Application object start along with it? And what is the exact sequence for this? Finally, when will it be destroyed in this…
4
votes
0 answers

IntentService blocking UI

I have one service(BackgoundService), one intent service (MyIntentService) and one process in my android app. UI hangs i.e. freezes completely when all three are running but it becomes so responsive when I stop the Intent Service. Also I am running…
Rojy Kumari
  • 159
  • 11
4
votes
3 answers

Sticky Service and Intent Service gets killed when the app is destroyed

In My app I am trying to download images even though user has force stopped it and exit it using recent app manager by swiping . Why I want this behavior, it has only one reason and that is : Because I want User to stop the download from my button…
Coas Mckey
  • 701
  • 1
  • 13
  • 39
4
votes
2 answers

Implement Bluetooth Connection into Service or Application Class without losing connection into a Device

i need some help, can you explain to me how can i implement the Bluetooth Connection from my Application into my Mini Thermal Printer Device. The scenario is like this. I already connect my application into device but when the Activity destroyed,…
4
votes
0 answers

Only one instance of an IntentService

I would like to setup an IntentService to fire on a timer and manually. In the case that new data is created I would like to 'manually' trigger the IntentService to send the data off immediately. The timer will just run every few minutes to ensure…
4
votes
1 answer

IntentService parallel execution

Following this question, I've a doubt. Let's say in my applicaiton I've defined 2 intent services that automatically starts after boot, i.e.
adam black
  • 607
  • 5
  • 14
4
votes
2 answers

onServicesDiscovered(BluetoothGatt gatt, int status) is never called

I have a BluetoothLeService which is called from IntentService. BLEService works fine until it connects. After it establishes the connection with iBeacon, it calls ; public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState)…
4
votes
1 answer

Multiple IntentServices running in parallel

I have an intent service in my Android app that is scheduled to start every one minute. Let me call this intent service intentServiceA.class Now I want to use another intentService (intentServiceB.class) for specific tasks. My question is: Does…
3
votes
2 answers

java.util.ConcurrentModificationException -- bug when performing IO operations (not with a list)

Ok. Here is the scenario. I have a form that the user fills out to create a Match object. I use an IntentService to write the information to file on a background thread. If a boolean of "true" is passed in the intent, then a corresponding ScoreFile…
Jo Momma
  • 1,126
  • 15
  • 31
3
votes
1 answer

How to solve ' ANR Reason: executing service ' Error from service class?

I am using IntentService for background music. It will not working with above 7.1 (Nougat) devices.I want to play music on background, and also control play, pause and stop actions from application class. My code is.. Application class... public…
3
votes
1 answer

Why is not possible to declare an Intent Service as package private?

I'm working on a android library, so I wish to keep all the library code package private apart from a few classes which the library user needs to access. Among these classes is an IntentService. However, the app crashes with this error :…
vepzfe
  • 4,217
  • 5
  • 26
  • 46
3
votes
1 answer

How to stop notification's service on Android Oreo

Our app has some services and intent-services that starts running when the user starts the app. These components needs to be started to continue the process running even if the user minimize the app. On Android Oreo our app started crashing due the…
3
votes
3 answers

Android Oreo service restriction affect intentservices from job schedulers?

With the new background service restrictions introduced in Oreo, I'm having a hard time finding a place to clarify whether IntentServices can still be launched from a JobScheduler while the app is backgrounded. I have a very important feature based…