Questions tagged [foreground-service]
723 questions
72
votes
8 answers
What is the proper way to stop a service running as foreground
I am trying to stop a service which is running as foreground service.
The current issue is that when I call stopService() the notification still stays.
So in my solution I have added a receiver which I am registering to inside the onCreate()
Inside…

user1940676
- 4,348
- 9
- 44
- 73
62
votes
3 answers
What is the difference between a background and foreground service?
I am currently writing my first Android application and I keep running into references to background and foreground services. Since I intend on using a service in my application I was hoping to get a clarification between the two and how they are…

Andrew Guenther
- 1,362
- 2
- 12
- 30
35
votes
3 answers
Sticky foreground service fails to restart with a "process is bad" error
I have a started foreground service.
I've taken care to return START_STICKY from onStartCommand.
I've observed that foreground services don't run indefinitely but are periodically terminated by an Android internal module called the…

farthVader
- 888
- 11
- 19
34
votes
5 answers
How To Start An Activity From Background in Android 10?
I am building an android app where I need to start an activity from background. I am using a ForegroundStarter which extends Service for accomplishing this. I have an activity Adscreen.class which I need to run from my Foreground service. The…

SK707
- 381
- 1
- 3
- 8
33
votes
8 answers
Android 9 (Pie), Context.startForegroundService() did not then call Service.startForeground(): ServiceRecord
First of all,
I looked at these;
Context.startForegroundService() did not then call
Service.startForeground()
Context.startForegroundService() did not then call Service.startForeground
Android 9 (Pie) Only: Context.startForegroundService() did not…

Beyazid
- 1,795
- 1
- 15
- 28
28
votes
3 answers
Why did Android 13 remove the Foreground Service notification?
Sorry for the sort of click-bait title; I couldn't think of a more concise way to say it.
In Android 13, if the user doesn't grant the "dangerous" POST_NOTIFICATION permission, then Foreground Service notifications are not shown in the Notification…
user19309143
27
votes
3 answers
Oreo - Foreground service does not show foreground notification
So far, I've adjsuted my code to use ContextCompat.startForegroundService(context, intentService); to start my service. This way, it works on android < 26 and on android 26 (Oreo) as well.
I still see a difference, in android oreo I don't see my…

prom85
- 16,896
- 17
- 122
- 242
23
votes
1 answer
NPE when startForeground
NPE reported in crashlytics only for Android O and above. I just startForegroundService and the service startForground in onCreate method and the NPE happened.
In crashlytics it happened when startForeground(NOTIFICATION_ID_TOOLBAR,…

user3162215
- 357
- 1
- 9
16
votes
7 answers
Media projections require a foreground service of type ServiceInfo.FOREGROUND_SERVICE TYPE_MEDIA_PROJECTION in Android Pie and Q
any body knows why this error occur, Media projections require a foreground service of type ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION on getMediaProjection() even i call getMediaProjection() method after calling startforeground()…

Mirza Ali
- 171
- 1
- 1
- 7
16
votes
1 answer
How to cancel an ongoing notification of another app?
Background
I've found an app that somehow hides heads-up notifications, including even ongoing notifications (used by foreground services), called NCleaner .
I was wondering how such a thing works.
The problem
There isn't much information of how to…

android developer
- 114,585
- 152
- 739
- 1,270
15
votes
0 answers
WorkManager - SystemForegroundService: Context.startForegroundService() did not then call Service.startForeground()
For fetching the location from foreeground service, we have recently migrated our WorkManager to use ForegroundService. We have followed the below document to achieve…

Chandra Sekhar
- 18,914
- 16
- 84
- 125
14
votes
4 answers
App keeps running when foreground service is stopped last
I came across a behaviour in Android's process management in conjunction with foreground services, that really confuses me.
What is reasonable for me
When you swipe your app from 'Recent apps', the OS should
finish the app process in the relatively…

Christoph Lutz
- 141
- 1
- 5
14
votes
1 answer
Is it possible to put a foreground service notification in a notification channel with IMPORTANCE_MIN?
I am currently working on transitioning an application to Android O, and I am currently working on notification channels.
I have made different channels with different importance levels and since the application has a foreground service that has to…

Anax
- 312
- 3
- 12
13
votes
2 answers
StartForeground for IntentService
I have an IntentService and I want to make it sticky with an ongoing notification. The problem is that the notification appears and then disappears immediately. The service continues to run. How should I use startForeground() in an…

Matroska
- 6,885
- 14
- 63
- 99
13
votes
1 answer
Foreground service when user disables notifications
I have the next doubt:
I am working on an app that needs to start a foreground service. I know that since Android O, you need to attach a notification to that foreground service. So far so good.
The question is: what happens if the user disables…

Leandro Ocampo
- 1,894
- 18
- 38