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
40
votes
2 answers

Can you use a LoaderManager from a Service?

I have a data loading system set up using a custom Loader and Cursor that is working great from Activities and Fragments but there is no LoaderManager (that I can find) in Service. Does anyone know why LoaderManager was excluded from Service? If…
40
votes
8 answers

Unable to start service Intent: not found

I've the same issue described here but i can't understand whats wrong. My issue is: Unable to start service Intent { act=.connections.MoodyService } U=0: not found EDIT I've changed my package from connections to service in the source code, sorry…
firetrap
  • 1,947
  • 3
  • 24
  • 39
39
votes
2 answers

Using Dagger 2 to inject into service

I have an app which is basically a service that runs all the time and alarms the user when something happens. When the service creates the alarm, it needs to give it his context so that the alarm can do callbacks to the service when something…
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…
39
votes
10 answers

Background Service getting killed in android

We have developed an Android Application which involves a service in the background. To implement this background service we have used IntentService. We want the application to poll the server every 60 seconds. So in the IntentService, the server is…
Ashwin
  • 12,691
  • 31
  • 118
  • 190
38
votes
7 answers

Android background music service

I am developing an entertainment app in android. I want to play background music, and I want to use service for that. App have 3 activities and music must be played across all activities. Also, when activity is paused, music must PAUSE and stopped…
Rohit
  • 2,538
  • 6
  • 28
  • 41
38
votes
1 answer

Using Google Play Services LocationClient in background service

My app is designed to track user's location periodically and send it to server, Recently I changed my code with Google play services Location API. I created the locationclient and connected to the service in onStartCommand public int…
Thiyaga B
  • 971
  • 1
  • 9
  • 26
38
votes
3 answers

how to start service from fragments

I want to start service from fragment from a list view item. I am trying to call service with: startService(new Intent(getActivity(),myPlayService.class)); But it wont work at all. How do i call my service from fragments? Is there any another way…
Swap-IOS-Android
  • 4,363
  • 6
  • 49
  • 77
37
votes
2 answers

How to start Service using Alarm Manager in Android?

In my application, I am trying to start a service using Alarm manager. When I am clicking a button service should start in a particular time which I am giving. My code for Alarm Manager is given below: public void onClick(View view) { if(view…
Arindam Mukherjee
  • 2,255
  • 11
  • 48
  • 83
37
votes
6 answers

How it is possible Service run indefinitely and also allow binding in android?

I want a service which can run in the background until I stop, even if the component that started it is destroyed and also allows binding to the activities. How it is possible ? As per android bound services document - there are three ways of…
Khushbu Shah
  • 1,603
  • 3
  • 27
  • 45
37
votes
3 answers

Injecting a repository into a Service in Android using Hilt

I have an Android project with Hilt dependency injection. I have defined MyApplication and MyModule as follows. @HiltAndroidApp class MyApplication : Application() @Module @InstallIn(ApplicationComponent::class) abstract class MyModule { …
MikkoP
  • 4,864
  • 16
  • 58
  • 106
37
votes
3 answers

Services and ViewModels in Android MVVM - How do they interact?

I've been using ViewModels from Android Architecture for some time now, and abide by never exposing the ViewModel to Context/Views (Android Framework/UI). However, recently I have run into an interesting problem. When making a timer app, when a…
37
votes
7 answers

Samsung "App optimisation" feature kills background applications after 3 days

We are currently developing an Android app that is a fitness-tracker application. It runs constantly in the background, and it works fine on most devices, but we've been having issues with the application dying completely on some Samsung devices.…
37
votes
7 answers

How to restart service in android to call service oncreate again

I have a service in my Android Application which runs always.Now i have a settings from my server through GCM and update these settings to my service. I put my settings in oncreate of service. So i need to restart my service to fetch latest…
Ramprasad
  • 7,981
  • 20
  • 74
  • 135
36
votes
4 answers

Can anybody explain what is difference between unbound and bound service in android

Can anybody explain what is difference between unbound and bound service in android and explain about intent service Thanks
mohan
  • 13,035
  • 29
  • 108
  • 178