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

Cannot keep Service running in Android

I tried the threads: Cannot keep android service alive after app is closed Android Service Stops When App Is Closed I tried that without success I want to keep a IntentService running in background even when the app is killed. But if I remove my app…
Son
  • 77
  • 1
  • 6
2
votes
1 answer

Android Service Won't Restart On Android 8.1

I have a class extending the service class. I start my service from my MainActivity but the service won't restart on closing the app on android 8.1 In my service class I have the following code: @Override public int onStartCommand(Intent intent,…
adb adb
  • 21
  • 1
2
votes
2 answers

chronometer not running in service

I am trying to run chronometer inside a Service. But I am not able to run it. I press a button in Activity and that event is passed to the Service. If the button in pressed then start the Chronometer but problem is setOnChronometerTickListener is…
sagar suri
  • 4,351
  • 12
  • 59
  • 122
2
votes
1 answer

How to stop all services, threads, unload libraries on android app kill

I want to give user ability to choose language of application UI and content in it with different languages. I want to reload new fresh localized data from server with new language which user select. To do application recreation with new language…
yozhik
  • 4,644
  • 14
  • 65
  • 98
2
votes
1 answer

Which Service on Wear OS for permanent running in background

I wrote an MQTT Android app on my smartphone and used a normal background service. Now I want to write the same app for a smartwatch with Oreo 8.0. I read some articles about services in Oreo and now I'm really confused. The recommandation is to use…
Brownie
  • 27
  • 3
2
votes
1 answer

Can device sleep before foreground service?

I know that previously we needed to use WakefulBroadcastReceiver to ensure that between receiver onReceive and service onHandleIntent the device doesn't fall back asleep. Now Google seems to have deprecated WakefulBroadcastReceiver because it's not…
rcell
  • 671
  • 1
  • 10
  • 17
2
votes
1 answer

Using mqtt to send push notification , not working when swiped from recent apps

using mqtt for push notification in android with following libs : implementation 'org.eclipse.paho:org.eclipse.paho.android.service:1.1.1' implementation 'org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.1.0' i followed this tutorial , the problem…
2
votes
1 answer

How can WorkManager be used for widget updating?

Android Oreo (8.0) makes it very hard to update widgets (1,2,3) either by clicking a button (PendingIntent) or automatically updating every X minutes. I am looking into how I could use the new WorkManager for this. I was able to use if for…
c0dehunter
  • 6,412
  • 16
  • 77
  • 139
2
votes
0 answers

App keep Crashing on Oreo : android.app.RemoteServiceException: Context.startForegroundService() did not then call Service.startForeground()

App keeps crashing on Oreo Versions and my knowledge is limited so please share and in other versions its working fine.This error occures and crashes when i try to login (api) and returns to a page which is similar to facebook feed page and it have…
2
votes
0 answers

Use Google text recognition to get text displayed on the screen

My goal is to use an OCR library to get the text displayed on the screen. Example : you are on the youtube app, normally you can't copy the description. My project is to get this text that I can't copy. I actualy use a Service that overlays a button…
remjln
  • 41
  • 4
2
votes
1 answer

Handler not executing Runnable in Instrumentation Test

I have written an Android instrumentation test that calls my service and receives an answer via an broadcast. The code to be tested, which speaks to the service, uses handler. In process of testing my test ^^ I noticed that the handlers are not…
addyi
  • 83
  • 1
  • 5
2
votes
1 answer

Android service binding fails unless app is open in background (One Plus 5)

I have 2 separate Apps A and B. Application B has a service inside it and at one point, Application A communicates with App B by binding to B's service and exchanging some messages (using a Messenger). On almost all devices, this process works…
George V.M.
  • 757
  • 7
  • 16
2
votes
1 answer

Detect system reboot from inside a service

Is it possible to detect when a service is stopped or destroyed by one of its own methods? e.g. onDestroy() (not currently working) What I need is to detect, from inside the service, whenever the device is rebooted or turned off.
Mr. Thanks a lot
  • 235
  • 4
  • 17
2
votes
3 answers

Firebase Cloud Messaging onMessageReceived not working with ShortcutBadger

I'm using Firebase Cloud Messaging to send notifications and ShortcutBadger to update the unread messages count on our app badge. I've extended the FirebaseMessagingService class and implemented the override method onMessageReceived, which seems to…
nurider
  • 1,555
  • 1
  • 18
  • 21
2
votes
2 answers

"RuntimeException: Canvas: trying to use a recycled bitmap android.graphics.Bitmap" trying to pass Bitmap from Activity to a Service

I'm writing a small Android program in Android Studio that uses MediaProjection to grab a screenshot of the whole screen and then I want to pass that screenshot as a Bitmap to my System Overlay (based on the chatheads example). When the…