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.

1118 questions
10
votes
1 answer

Why does it matter where the Toast is made in Android if the context is the same?

I have a legacy IntentService that attempts to use Toast messages to display error messages.1 I'd like the messages to be displayed, and have added code to get them on the correct thread. The simplest change would be to pass in the constructed…
blahdiblah
  • 33,069
  • 21
  • 98
  • 152
9
votes
3 answers

Android Oreo JobIntentService Keep running in background for Android 7 &below and crashing often in Android 8 & above

I have recently replaced all my service to foreground services and JobIntentService since there are some background execution limits (https://developer.android.com/about/versions/oreo/background) in oreo and above. As per documentation,…
Kalai.G
  • 1,610
  • 13
  • 22
9
votes
2 answers

IntentService + WakefulBroadcastReceiver + AlarmManager are deprecated with API 26 (Android 8.0 Oreo). Which is the best alternative?

Sometimes in my apps I need to do something in the background repeatedly (every X hours). Up to API 25 i use: AlarmManager with setInexactRepeating (to respect battery) WakefulBroadcastReceiver to have enough times to do all works IntentService to…
Alessandro Scarozza
  • 4,273
  • 6
  • 31
  • 39
9
votes
1 answer

Data change in IntentService

I'm using IntentService for handling my messages from push notification from FCM. It works perfectly as required when the message comes one by one but when the device is not connected to the network and after when device again connected FCM send the…
baldraider
  • 1,049
  • 2
  • 18
  • 48
9
votes
1 answer

What happen when my Activity is destroyed when I'm using IntentService with ResultReceiver

I have searched through the net to find this answer. But no result found. Sorry that I'm a very newbie in Java & Android programming. I would elaborate on my question more. Let say my Activity started an IntentService and it's running independently…
9
votes
2 answers

How to correctly handle startForegrounds two notifications

I have an IntentService that uploads a file. Everything works fine, but I'm a little confused about how to handle the notifications. When I start the notification I use startForeground() because the files can be rather large and I don't want the…
Jason
  • 1,238
  • 1
  • 15
  • 18
9
votes
1 answer

How download file with service in android?

I want download a file from internet with service. I found the source code and the code worked well. But i have a problem when i back from app the download are stopping or when i clear RAM, it also are stopping. So that i want found downloading code…
Musagil
  • 145
  • 1
  • 2
  • 12
9
votes
3 answers

NetworkOnMainThreadException in IntentService

I am making network calls from an IntentService but still receiving a NetworkOnMainThreadException. My understanding is that an IntentService always runs on a worker thread, so I'm suprised to see this. The crucial piece may be that my…
click_whir
  • 427
  • 5
  • 19
9
votes
1 answer

Is the rest client app design approach in google io 2010 still up to date?

two years past, there comes fragment, intent service, cursor loader. Is the approach still up to date, or is there any better or mature pattern to design an android rest client, especially compare to the option B (I don't have the privilege to post…
Ren Ji
  • 115
  • 7
8
votes
2 answers

How to remove duplicate intent from JobIntentService

I have a JobIntentService that is launched every time a push notification comes in to tell the service to go fetch more data. While the app is in the foreground everything works as it should. When the app is in the background and multiple push…
tyczj
  • 71,600
  • 54
  • 194
  • 296
8
votes
2 answers

How to dispose Rx in WorkManager?

I implemented an AlarmManager to send notifications when user adds a due date to a Task. However, when the user turns off the device, all the alarms are lost. Now I'm updating the BroadcastReceiver to receive an android.intent.action.BOOT_COMPLETED…
8
votes
2 answers

java.lang.RuntimeException unable to instantiate service: java.lang.NullPointerException

I was trying to create an activity that start a service (in a new thread). It consists in a layout with two editText and a button called Send. The point is that when I execute the MainActivity, it throws that: 06-15 22:32:13.312:…
Mitodina
  • 580
  • 2
  • 5
  • 11
7
votes
1 answer

How to test IntentService android?

How can I test an IntentService in android without using the deprecated ServiceTestCase? From the documentation of the ServiceTestCase: This class was deprecated in API level 24. Use ServiceTestRule instead. New tests should be written using the…
7
votes
2 answers

Service has leaked ServiceConnection that was originally bound here

I am using a BraodCastReceiver that starts an IntentService. Everythings look working good, but I get this error which I don't know its source: android.app.ServiceConnectionLeaked: Service com.merchantech.app.smartdiscount.MyIntentService has…
HiddenDroid
  • 1,440
  • 4
  • 14
  • 27
7
votes
6 answers

Background Process to scan the location of the user at regular intervals and update the local database even when the app is not open

I am creating an app that checks for user locations every half an hour and updates the location of the user in the local database and then runs CRUD queries based on the user's location even when the app is not running. How do i do it ? I have…
Sagar Devanga
  • 2,815
  • 27
  • 30