Questions tagged [android-intentservice]
The IntentService class provides a straightforward structure for running an operation on a single background thread.
460
questions
823
votes
11
answers
344k
views
Service vs IntentService in the Android platform
I am seeking an example of something that can be done with an IntentService that cannot be done with a Service (and vice-versa)?
I also believe that an IntentService runs in a different thread and a ...
143
votes
8
answers
121k
views
What is the difference between an IntentService and a Service? [duplicate]
Can you please help me understand what the difference between an IntentService and a Service is?
52
votes
5
answers
17k
views
android design considerations: AsyncTask vs Service (IntentService?)
I'm designing an android app which will need to do the following steps:
user pushes a button or otherwise indicates to "sync data".
sync process will use REST web services to move data to and from ...
48
votes
5
answers
64k
views
Android RuntimeException: Unable to instantiate the service
I want to create a service which will run on a separate thread (not on UI Thread), so I implemented a class which will extend IntentService. But I haven't got any luck. Here is the code.
public class ...
27
votes
2
answers
6k
views
IntentService's onHandleIntent(Intent) gets null argument
I'm using an IntentService to run a background service for my app on android. Oddly I'm getting a lot of crash reports with cases where the intent passed to onHandleIntent is null. I'm not even sure ...
24
votes
2
answers
28k
views
Android IntentService can't instantiate class; no empty constructor
I have a MainActivity class that needs to access an online API (thus using network resources). This requires a background thread that I've created in a separate file HttpRequestService.java.
...
22
votes
2
answers
16k
views
How to keep an IntentService running even when app is closed?
In my Android app I start an IntentService from within an Activity by calling
startService(new Intent(this, MyService.class));
And it works like a charm. I can move between Activies, press the Home ...
18
votes
3
answers
17k
views
What are differences between JobIntentService and IntentService?
I do not understand what difference between those two APIs. I mean when to use the first one. Why is there JobIntentService ?
Thanks in advance
18
votes
3
answers
25k
views
Realm `access from incorrect thread` error when using shared code between IntentService and AsyncTask (Android)
I have some code that downloads a "Current" object's JSON. But this same code needs to be called by an IntentService whenever an alarm goes off (when the app is not running any UI), and also by an ...
17
votes
1
answer
7k
views
Android Service extends ResultReceiver for IntentService, how to implement CREATOR?
My app relies on a Service which stays in sync with external hardware in the background. Because the service operates on the main Thread, it does any heavy work asynchronously using an IntentService. ...
16
votes
5
answers
9k
views
Android: intentservice, how abort or skip a task in the handleintent queue
i have an activity ("ApplicationActivity") that call an intent service ("DownloadService")
The intentService download files from internet in background, but i want to be able to abort a specific ...
16
votes
1
answer
4k
views
Set "allow" permission by default in "Asus auto start manager" from code
I have an application which needs to run in the background, so I'm using a WakeFullService for that. But in Asus Zenfone it's not working because Auto start manager does not allow the app to run. My ...
15
votes
5
answers
2k
views
Geofencing : HTTP request failed while sending through the background service. Gives UnknownHostException
I implemented Geofence in android application. I followed this link to implement 'Geofence' in app. I am using 'Retrofit' library to call 'HTTP' request.
App has following permissions :
<uses-...
15
votes
2
answers
8k
views
JobIntentService doesn't start immediately on Android 8.0
I have implemented JobIntentService to do some background task which works fine on older Android devices (pre Android O). I see the intent is handled immediately but on Android O device there is some ...
15
votes
1
answer
23k
views
Native crash in /system/lib/libart.so
I have an app on the Play Store, it has an IntentService that does some work when the app starts, and it's causing native crashes on Android 5.0. This service just scans the assets folder for app ...
14
votes
2
answers
4k
views
ResultReceiver.send can only be called from same library group
I have an IntentService that is using android.support.v4.os.ResultReceiver to pass data. In the IntentService, when I use ResultReceiver.send method to send the result back, Android Studio shows an ...
14
votes
1
answer
8k
views
Android: multiple intentservices or one intentservice with multiple intents?
I'm a little confused about intentService. The docs say that if you send an intentService multiple tasks (intents) then it will execute them one after the other on one separate thread. My question is -...
14
votes
4
answers
3k
views
Service Automatic Called on Destroying Activity
I am stuck with the problem of Activity + Service in that I have following number of Activities and Services.
Activities:
LoginActivity => OrderListActivity => AddOrderActivity => ...
13
votes
2
answers
6k
views
IntentService + startForeground vs JobIntentService
Since Android Oreo background execution limits, the docs recommend to refactor IntentServices to JobIntentService.
https://developer.android.com/about/versions/oreo/background
JobIntentService runs ...
12
votes
2
answers
7k
views
Does FirebaseMessagingService run in the background by default?
Does the FirebaseMessagingService run in the background similar to how an IntentService operates?
I see that FirebaseMessagingService extents Service which does not run in the background, but I'd like ...
12
votes
1
answer
6k
views
Default constructor for IntentService (kotlin)
I am new with Kotlin and little bit stack with intentService. Manifest shows me an error that my service doesn't contain default constructor, but inside service it looks ok and there are no errors.
...
11
votes
7
answers
15k
views
handler.postDelayed is not working in onHandleIntent method of IntentService
final Handler handler = new Handler();
LOG.d("delay");
handler.postDelayed(new Runnable() {
@Override public void run() {
LOG.d("notify!");
//calling some methods here
}
}, ...
11
votes
2
answers
26k
views
IntentService is deprecated, how do I replace it with JobIntentService?
Following FetchAddressIntentService implementation with IntentService (in kotlin):
class FetchAddressIntentService //Constructor of this service
: IntentService(INTENTTAG) {
//Receiver ...
11
votes
2
answers
5k
views
Does intent go queue when calling startService for IntentService multiple times?
I want to download from internet with a IntentService. I pass a url through Intent to IntentService by calling startService(intentserive);.
If I call startService for a various intents, do the ...
11
votes
2
answers
806
views
Database operations in IntentService results into application halt,become unresponsive and giving ANR
I am using an IntentService in a alarm manager to trigger it after every 15 seconds.
I have to continuously send large amount data to server and receiving large amount of data in response in ...
10
votes
2
answers
4k
views
Asking an IntentService for information about its queue
I have an IntentService that queues up web service calls that need to be made to my web server. So each Intent is a web service call to be made.
I'd like to set something up where my application can ...
10
votes
2
answers
2k
views
HandlerThread vs IntentService
I would like to ask someone to explain me please, what are the main differences between HandlerThread and IntentService, and what are the main use-case scenarios?
I understand that HandlerThread ...
9
votes
3
answers
2k
views
Is there any development pattern that can replace an IntentService for network requests?
In the current app that I am developing with a co-worker, we're using IntentServices with Volley calls inside to process RESTful API network requests. It's just simple JSON string data, and some small ...
9
votes
6
answers
4k
views
Should I use Service or IntentService for my android app?
Please correct me If I am wrong :
1) A Service is used to perform long tasks in background. A service runs in the UI thread so if there comes a long task then it may freeze our UI. A service will ...
8
votes
2
answers
2k
views
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 ...
7
votes
2
answers
20k
views
Unable to find explicit activity class {}; have you declared this activity in your AndroidManifest.xml
I'm trying unzip some files in background, so I use IntentService like in google's tutorial. My service class declared in AndroidManifest like this:
<manifest xmlns:android="http://schemas....
7
votes
1
answer
3k
views
null intent redelivered to Service onStartCommand()
In the Android documentation, the Service's "onStartCommand()" has an intent given as a param, that according to the docs:
"the Intent supplied to startService(Intent), as given. This may be null if ...
6
votes
4
answers
34k
views
Run a service in background continuously
Run a service in background continuously. For example, a service has to be kicked off which will display a toast message 20 seconds once even if the app is closed.
public class AppService extends ...
6
votes
2
answers
2k
views
IntentService - find number of Intents waiting in the queue
In my app I use an IntentService to do some work. I want to find out how many intents are waiting to be processed, as IntentService holds them in a 'work queue' , and sends the next one to ...
6
votes
1
answer
23k
views
How to start an IntentService from a WakefulBroadcastReceiver
I have an application, which you should be able to recreate entirely and very easily with the code I'll post in this question. Here's the Manifest file:
<?xml version="1.0" encoding="utf-8"?>
&...
6
votes
2
answers
12k
views
Android: How to determine if IntentService is running?
I have an activity for upload from which I am calling Intent service. In there I am handling the API request call.
I want an activity to know whether the service is running or not, to show an ...
6
votes
1
answer
2k
views
Android IntentService triggered with null intent
I'm seeing a crash in Crashlytics:
Fatal Exception: java.lang.NullPointerException: Attempt to invoke
virtual method 'int
android.content.Intent.getIntExtra(java.lang.String, int)' on a null
...
6
votes
2
answers
716
views
Nearby Messages using an IntentService
Initially I setup a BroadcastReceiver to receive intents from the Nearby Messages API.
class BeaconMessageReceiver : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent)...
6
votes
3
answers
2k
views
startActivity() doesn't work when app is in background (In this special case)
I'm trying to bring my app from background to foreground. In onHandleIntent() of my custom IntentService class, I have:
Intent intent = new Intent();
intent.setClass(getApplicationContext(), ...
5
votes
2
answers
5k
views
Android - Running a IntentService multiple times
So I have a IntentService that runs fine when I run it a single time. It takes an image manipulates it then outputs a series of RGB values.
But what I now need it to do is run multiple times to ...
5
votes
4
answers
7k
views
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 ...
5
votes
3
answers
12k
views
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 ...
5
votes
1
answer
2k
views
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 callbacks
http://lalit3686....
5
votes
5
answers
8k
views
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 ...
5
votes
2
answers
17k
views
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 ...
5
votes
1
answer
7k
views
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 ...
5
votes
2
answers
601
views
Are separate intent services queued on the same thread?
I have two intent services - IntentServiceA and IntentServiceB
They have the following class definitions:
public class FirstService extends IntentService {
public FirstService() {
super("...
5
votes
1
answer
901
views
Best approach to execute service in Android
I have a service that have an variable life time. It may execute from 5 minutes to 2 hours (for example). So I'm looking for the best approach to do that, and my service must achieve the following ...
5
votes
2
answers
991
views
Geofence works but after a while stops triggering
My Geofence is working at start but then all of a sudden after a day or two stops triggering, is there a problem on Google side here or my code?
Upon boot and starting the app I use an IntentService ...
5
votes
4
answers
539
views
Login Screen showing progressdialog and allow screen orientation change
Hello i am trying to implement a log in screen showing a progress dialog and allowing the phone to rotate.
I want to ask what is the best way to do that (IntentService, AsyncTask,Service) and ...