Questions tagged [background-service]

A background service is a computer service that runs "behind the scenes" (i.e. in the background) and without user intervention.

889 questions
267
votes
13 answers

startForeground fail after upgrade to Android 8.1

After upgrading my phone to 8.1 Developer Preview my background service no longer starts up properly. In my long-running service I've implemented a startForeground method to start the ongoing notification which is called in on…
Rawa
  • 13,357
  • 6
  • 39
  • 55
116
votes
9 answers

Android Starting Service at Boot Time , How to restart service class after device Reboot?

I need to start a service at boot time. I searched a lot. They are talking about Broadcastreceiver. As I am new to android development, I didn't get a clear picture about services on Android. Please provide some source code.
harish
  • 1,755
  • 6
  • 22
  • 36
114
votes
5 answers

How to update LiveData of a ViewModel from background service and Update UI

Recently I am exploring Android Architecture, that has been introduced recently by google. From the Documentation I have found this: public class MyViewModel extends ViewModel { private MutableLiveData> users; public…
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…
58
votes
11 answers

How to check MIUI autostart permission programmatically?

I need to check programmatically if the auto start permission for my app in MIUI phone is on or off. Facebook and whatsapp have this permission already enabled by default , how can I do so?
39
votes
1 answer

Android application as a service without activity

I am making a set of apps and I have pretty much the same background service for all of them. I'm trying to make an app that has only this Service. so I don't repeat it in all of them, but the thing is don't need any Activity. because there is no UI…
38
votes
6 answers

Android Background Service is restarting when application is killed

I am developing an application in which a background service is created to collect sensor data. I am starting the service from my activity: startService(new Intent(this, MyService.class)); I created the service so if the application is destroyed,…
duncanportelli
  • 3,161
  • 8
  • 38
  • 59
37
votes
3 answers

Difference between ExecuteAsync and StartAsync methods in BackgroundService .net core

Migrating from the legacy .NET Framework I need to create a long time background process worker. Looking at the documentation I found a BackgroundService class, which is used for this kind of purpose. But I stumbled across two the same (for my…
osynavets
  • 1,199
  • 1
  • 12
  • 22
37
votes
4 answers

Execute task every second using Work Manager API

Work Manager is a new API and I try to execute task every second, but it doesn't work. This is my worker class class TestingWorker : Worker(){ override fun doWork(): Result { Log.i("CheckWorker","Result here") return…
36
votes
4 answers

iOS: Keep an app running like a service

In iOS, how would I instruct the OS to keep my app running even if it is no longer in the foreground? Skype Viber Empatica Zenly And many more apps does this.
Ian Vink
  • 66,960
  • 104
  • 341
  • 555
34
votes
3 answers

Get location in Ionic/Cordova app when in background

Is it possible to run a background service if I close my Ionic/Cordova app (both for iOS and Android) ? For the purpose I picked that pluging https://github.com/katzer/cordova-plugin-background-mode So far I have that…
radioaktiv
  • 2,437
  • 4
  • 27
  • 36
21
votes
4 answers

How to run BackgroundService on a timer in ASP.NET Core 2.1

I want to run a background job in ASP.NET Core 2.1. It has to run every 2 hours and it will need to access my DI Container because it will perform some cleanups in the database. It will need to be async and it should run independently of my ASP.NET…
21
votes
1 answer

Android Silent Push

I am new to android and I'm playing around trying some features here and there. I wanted to know what is the way to use silent push - meaning get a push notification on the device without any alarm, notification or vibration - i.e. without the user…
20
votes
1 answer

Voice Recognition as a background service

Is it possible to implement an activity as a service? My activity is a voice recognition activity. I want to have the activity running in the background of the app constantly checking for voice and when the user says a command it will recognize it…
IZI_Shadow_IZI
  • 1,921
  • 4
  • 30
  • 59
17
votes
3 answers

Async timer in Scheduler Background Service

I'm writing a hosted service in .Net-Core which runs a job in the background based off of a timer. Currently I have to code running synchronously like so: public override Task StartAsync(CancellationToken cancellationToken) { …
johnny 5
  • 19,893
  • 50
  • 121
  • 195
1
2 3
59 60