Questions tagged [android-service]

A Service is an application component representing either an application's desire to perform a longer-running operation while not interacting with the user or to supply functionality for other applications to use.

A Service is an application component representing either an application's desire to perform a longer-running operation while not interacting with the user or to supply functionality for other applications to use. Each service class must have a corresponding declaration in its package's AndroidManifest.xml. Services can be started with Context.startService() and Context.bindService().

Android Service Class Reference

Tutorials & Examples

6696 questions
2
votes
1 answer

Location updates not working in service when app is minimized

I have implemented a LocationListener to receive regular updates in a service when app is minimized. However this does not work. Updates are only received when the app is visible. Location updates cease when screen is locked or app is…
2
votes
0 answers

How to write Background Service in Android 6.0 and above?

I have created a background service and that service is working fine in below Android 6.0 when I kill app. Also working in Android 6.0 and above but only when I minimize app. When I kill app in Android 6.0 and above service also kill and not get…
2
votes
0 answers

JobIntentService runs again after exiting Doze mode

I'm running the following JobIntentService example from Google on Nexus 5X (Android 8.0) public class SimpleJobIntentService extends JobIntentService { /** * Unique job ID for this service. */ static final int JOB_ID = 1000; /** …
Renjith
  • 3,457
  • 5
  • 46
  • 67
2
votes
2 answers

NotificationListenerService not starting on Android Oreo

I have an app that uses the NotificationListenerService. It works perfectly on apis lower than Android Oreo, but specifically at Android Oreo, the system seems to not start the service when the user restart the app (it works at the moment the user…
Augusto Carmo
  • 4,386
  • 2
  • 28
  • 61
2
votes
2 answers

How to keep a local service running in between tabs?

I am currently working on a Pedometer application. At first, I started with one activity, the PedometerActivity. This activity started the service that is supposed to run in the background, and binds to it. The code is long so I'll just give…
2
votes
2 answers

Create service to detect any action from the user

I'm trying to create a service where I want to detect something about user, let's say when user lays the device on a table, the thing is that I have that action detected but I have it on a MainActivty and I want it to put on Service. The thing is…
StuartDTO
  • 783
  • 7
  • 26
  • 72
2
votes
1 answer

Running a new thread from IntentService

Suppose I want my app to sync data from an online database to the local database, I understand Services are the components to look for. If I start a normal service, I understand that it starts in the main thread and any time-consuming task I run…
2
votes
2 answers

Start JobService in foreground on Android

I use a com.firebase.jobdispatcher.JobService to sync data, I start it by scheduling a Job using FirebaseJobDispatcher. Problem: I don't like the delay before it runs on my very first app start. Is there a way in which I can start the service, on…
Frank
  • 12,010
  • 8
  • 61
  • 78
2
votes
1 answer

How to keep running foreground service in background also in android

I want to make an app turn on/off by shaking while screen locked as well as background, below is my code that runs only for foreground can you help me that how can foreground service can continue in background. MainActivty.java public class…
user3629
  • 57
  • 8
2
votes
1 answer

Android - Sending Many multi-part Messages will miss some of them

I'm new to android development. I want to send some SMS Message from my background service that it will fetch some data from the server and send it to some clients. So far it was working perfectly till they added some description to text messages.…
Pouya Samie
  • 3,718
  • 1
  • 21
  • 34
2
votes
3 answers

How to always run a background service even application gets killed by user from background

My Solution to write sticky service is working fine below Android version Lollipop but above Lollipop version service is getting closed when user kills the application from background. Any suggestion guys.
2
votes
1 answer

Notification action with Service inside PendingIntent doesn't work when app is not running

I have an app that allows responding to notifications through Notification.Actions. So basically, I have a Pending Intent with this Intent actionIntent = actionIntent = new Intent(this, NotificationActionIntentService.class); actionPendIntent =…
2
votes
2 answers

NetworkInfo.isConnectedOrConnecting() returns FALSE in Service

Faced a weird behaviour of NetworkInfo.isConnectedOrConnecting() when it is called from Service. It simply returns false although phone is connected to the Network. From Activities and Fragments this snippet works as expected. public boolean…
AnZ
  • 1,040
  • 24
  • 54
2
votes
1 answer

onSensorChanged not working after sleep for ~5 minutes until app is opened.

I'm facing some strange issue. I have a service which receives sensor updates. Everything works fine until screen turns off for a while. After that onSensorChanged is not called until I open the app from launcher. Here is my service class: public…
Paul Chernenko
  • 696
  • 5
  • 21
2
votes
1 answer

Android app in the background

I am developing an application in android studio, and I have to save the location of the device, I did a "locationService" class that extends service, so the location is segmented on my server and the service would be in the background. I have read…