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

Repeating IntentService using Timers- is it advisable?

I have an IntentService that downloads data from a server and I would like the IntentService to check for server updates at a certain interval. The following posts however advice against repeating a Service using a Timer - and instead emphasize on…
user1841702
  • 2,683
  • 6
  • 35
  • 53
3
votes
1 answer

Activity Recognition PendingIntent stop been called in the middle of the night

my application collects periodically Activity Recognition's Detected activity data. I implemented it exactly as described in the documentation , but with one minute interval. as long as the user is logged in - the application registered with a…
2
votes
1 answer

what approach should i follow to make Timer service in android

I am working on an interval timer which make an alarm every interval (E.g. 30mins). I want to make the timer work in background or when device is in sleep and show a notification, I was told to use Intent Service but its deprecated. what should i…
2
votes
0 answers

Unable to instantiate service, has no zero argument constructor

The Search : For days, I've been looking at how to control MediaPlayer which is running inside a Service. Basically, media controls in a ForegroundService/NotificationCompat And I read an answer,…
2
votes
2 answers

Unable to start receiver, app is in the background. AlarmReceiver to fire Notification

In my app, I use AlarmManager to start IntentService that accesses internal database of quotes and selects one randomly, then fires a notification with that quote. It is working perfectly on my phone which is Android 9, OnePlus6. But I receive lots…
2
votes
1 answer

My Android app always opens links instead of Android asking every time

My app is designed to work with various Amazon links but for some reason it has started to always open links instead of the Android system asking every time. If I click a link on the Amazon website in Chrome my app opens. If I click an Amazon link…
2
votes
1 answer

Permission error when trying to pass Content Uri from activity to service

I have an activity which accepts android.intent.action.SEND. It accepts some media files and texts. As it accepts a new 'share' it does some validation checks and pass the Uri to a service, it looks like this: Uri uri =…
2
votes
1 answer

How to queue multiple tasks in a foreground service, so that they execute one by one?

public class CopyService extends Service { private List taskList; private AsyncTask fileTask; @Override public void onCreate() { super.onCreate(); taskList = new ArrayList<>(); fileTask = new…
2
votes
1 answer

Android Design: Intentservice causing application not responding

I have designed a code which leads to application not responding. I have used okhttp3.WebSocket for continuous input stream of data on which i am deciding to start an IntentService which will be fetching data from server. I have an IntentService;…
2
votes
0 answers

Is it possible to IntentServices to be called out of order?

I have 2 calls to startService made on the same thread, but apparently these calls are received out of order in my IntentService. Our client says that the feature works on some devices and no on others, so I'm guessing this out of order could be…
Paulo Morandi
  • 147
  • 1
  • 10
2
votes
1 answer

Android Oreo background service is not working in doze mode?

I am using background service to get user location and upload to server. I have used one LocationTrack class which is extending Service class and AlramReciver which is extending BroadcastReciver. I have added all permission in manifest and register…
2
votes
2 answers

java.lang.IllegalStateException: Not allowed to start service Intent (from Activity onCreate)

I'm starting an IntentService from MainActivity:onCreate and I noticed this crash from the crash reporting only on Android Oreo above: java.lang.IllegalStateException: Not allowed to start service Intent {…
2
votes
1 answer

send results multiple times from IntentService

I have a IntentService that queries the MediaStore to get songs, albums, artist, whatnot. that way if someone tries to add an entire artist and there are a lot of albums the IntentService can do the expensive operations of getting all the albums…
Neglected Sanity
  • 1,770
  • 6
  • 23
  • 46
2
votes
1 answer

Home widget not refreshing on Oreo using JobIntentService

My app contains home widgets which are updated periodically using IntentService. Now, when targeting API level 26 I had to change this a little bit because of restrictions on Oreo. You can find more info here. I found this article in which it is…
2
votes
1 answer

How I can create a Background service in android?

I need to create a service that allow my application to work also when I close it, I’ve tried with STICKY_SERVICE but it doesn’t work... if anyone can decribe me how I can do this please answer this question. It works with android 7.1 and it doesn’t…