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
1
vote
0 answers

Best way to "kill" an Intent - Android

I have a Broadcast Receiver to receive notifications via GCM that are then handle by an IntentService as explained in the docs of Android developers. My IntentService creates a notification, when the user clicks in this notification the MainActivity…
1
vote
1 answer

How to receive Broadcasts when app is off?

How can I make an app respond to ACTION_SCREEN_ON broadcasts even when the app is off? I have been reading about alarms and IntentService but I am not sure what the best practice is. I am trying to make an app that takes pictures whenever the…
1
vote
1 answer

Using ContentProvider from an IntentService

I'm having problems using a ContentProvider from an IntentService. I plan to use an IntentService in my app to reschedule some alarms when the phone finishes booting up, but first I need to pull some data from the ContentProvider. According to these…
1
vote
1 answer

Android App Architecture

Let's say I have a simple app consisting of: A Fragment with a list view to display a list of books An Activity to hold the fragment Some web component that will issue a query to a server somewhere to get the list of books to display What's the best…
1
vote
1 answer

PendingIntent from Notification not received

I got an IntentService that does some long running work synchronously within onHandleIntent(Intent). So I'm showing a Notification for as long as the service runs. Now I would like to stop the service once the user taps onto the Notification. So…
1
vote
1 answer

Android how to pass array to activity from IntentService when Activity is already running

I have an IntentService that runs every 5 minutes. This service checks if there are any Alerts on the server. The Alerts are in a TwoDimensional ArrayList which i pass to an Activity to display in a list. At the moment if i start the app and let it…
turtleboy
  • 8,210
  • 27
  • 100
  • 199
1
vote
1 answer

is it possible to bind multiple components to intentservice in android

As of I know, we can use Bound service if we wanna bind multiple clients to a service. But, there are many advantages of intent service over a service. So, I am wondering if it is possible to bind multiple components to an intent service. Also, is…
1
vote
1 answer

android Service recreating and overlapping

When I start the app the value in the counter is posted for every 1000ms. The service is kept running even when the app is closed or screen is locked but when i start the app again the service is recreated and I see the counter starting from 0 and…
1
vote
1 answer

using a textview within an intentservice android

I have created a textview within my MainActivity and i need to pass this into my IntentService as I need to use the textview from MainActivity somewhere else. Is it possible to use the findViewById within an IntentService or is there a method in…
Dbucha01
  • 55
  • 7
1
vote
2 answers

Start service when the application exit (or is killed)

I would like to start my foreground service when my application is closed. I tryed OnStop() but it's not a good idea for me because it can trigger multiple times and i which it to run only one instance. I tryed OnDestroy() but it's simply doesn't…
Pilouk
  • 1,267
  • 1
  • 18
  • 36
1
vote
1 answer

How can I start a specific Method of my IntentService?

(1) From an activity, can I call a specific Method (action) of my IntentService? Using the sample code below, I would like to call ONLY ACTION_BAZ: public class MyIntentService extends IntentService { private static final String ACTION_FOO =…
Clayton
  • 381
  • 4
  • 13
1
vote
1 answer

Can two different intentservices run concurrently? Does OS wait for first intentservice to stop before starting second intent service?

I have two intentservices: IntentServiceA and IntentServiceB. While IntentServiceA is running and if I call startService(IntentServiceB) , will IntentServiceB run concurrently with IntentServiceA or does it wait till IntentServiceA stops? If it…
achavan804
  • 13
  • 3
1
vote
1 answer

Can an application bind on the intentService of another application, when the intent service is not started/running?

The IntentService also has the onBind method. BindService call onto a non running service would start the service similarly would it do so for IntentService?
CP90
  • 21
  • 5
1
vote
1 answer

Toast from IntentService posted with handler doesn't show when handler created in onHandleIntent

I'm currently trying to show a toast from IntentService, if a device detects an accelerometer. To do so, I searched and learned that I can implement an Handler. However, it is not quite working. The code compiles and runs on an emulator without any…
ElectroJunkie
  • 301
  • 5
  • 16
1
vote
1 answer

Android InstantiationException : No empty constructor

I get an InstantiationException when I try to start an IntentService. I have looked at other threads here but the answers don't solve my problem. My service class does have a default constructor. Here's my service class. (It is defined in a file…