Questions tagged [android-service-binding]

In Android applications, a bound service is an implementation of the Service class that allows other applications to bind to it and interact with it. Service binding is used to allow services to be consumed from other components.

In Android applications, a bound service is an implementation of the Service class that allows other applications to bind to it and interact with it. Service binding is used to allow services to be consumed from other components.

More Info

420 questions
67
votes
8 answers

Android java.lang.IllegalArgumentException: Service not registered

I have a setup that looks something like this: class MyFragment implements SomeEventListener { Application mAppContext; boolean mBound; boolean mDidCallUnbind; MyIBinder mBinder; ServiceConnection mConnection = new…
dcow
  • 7,765
  • 3
  • 45
  • 65
32
votes
4 answers

How to communicate between Firebase Messaging Service and Activity? Android

I know the question about how to communicate between a service and an activity has been answered many times but I also want my own way of doing this to be reviewed and to know if its an acceptable and the right way to do this and what are the…
18
votes
1 answer

Service: onTaskRemoved not called if started with bindService

I have a Service in which the onTaskRemoved() method has been implemented. When the service is started with startService() the function onTaskRemoved() is called when the app is removed from the recent-apps-list by swipe. But if the service is…
surlac
  • 2,961
  • 2
  • 22
  • 31
17
votes
4 answers

How to restart service after the app is killed from recent tasks

I have created a service to fetch current location of the device in periodic intervals. I want the service to run in the background even if the app is cleared from recently opened apps. Currently the service runs in background only until app is…
17
votes
3 answers

java.lang.ClassCastException: android.os.BinderProxy cannot be cast to LocalBinder

I have a Service that I am trying to bind to my main Activity, but I am receiving a java.lang.ClassCastException: android.os.BinderProxy cannot be cast to com.walintukai.rubix.ConnectionService$LocalBinder. I have declared the service in my…
14
votes
1 answer

Creating unbound service in Kotlin

I'm trying to create a simple unbound service in kotlin, but I can't. When I override onBind() method in Java I can return null, but in kotlin it says I'm only allowed to return IBinder and not IBinder?, that means it can't be null. Any ideas how to…
frozzyk
  • 475
  • 7
  • 16
14
votes
2 answers

How to run a singleton (shared) service in a library for multiple applications?

I've written a library starting a service in the background. It runs perfectly in all applications. In order to reduce the RAM usage, I want to avoid running multiple services for different applications. Actually, it's pretty enough to use only one…
13
votes
4 answers

Getting java.lang.ClassCastException: android.os.BinderProxy every time i declare and run two services

I am encountering following binder.proxy exception every time i declare and run two services. One service runs in different Process(Private to app) and another service runs in same process as My Application is running in(Default App Process) with a…
12
votes
1 answer

Activity with long-lasting service in the background that will not be killed

On Android, I have an Activity called FirstActivity which starts a Service named MyService to do networking stuff in the background. The Activity and the Service communicate with each other all the time by calling methods. Now when the user…
caw
  • 30,999
  • 61
  • 181
  • 291
11
votes
1 answer

How do I detect skype/telegram/whatsapp calls when my messenger app is in a call or wants to make a call?

I am wondering if there is a way I can detect a skype call/telegram/whatsapp/fb messenger call etc in progress or incoming call etc just like the regular phone call with telephony manager/listener? I would like to have some kind of mechanism that…
user2386226
11
votes
2 answers

Overlay Window Service In Android

I have to implement an Overlay Window like True Caller App has.But the problem I am getting is, During any Incoming or Outgoing call my service automatically getting close or destroyed. Service class public class OverlayService extends Service…
11
votes
4 answers

Bind to service from new Context for configuration changes or bind from app context?

I'm trying to work out if bound service is appropriate for doing background work in my app. The requirements are that various application components can make web requests through it of varying priority. (Thus the service must maintain some sort of…
10
votes
3 answers

Android: java.lang.IllegalArgumentException: Service not registered

I have activity, that starts service and binds it. But I want my service to run even if the activity is closed, so I need to unbind it. When i am trying to do so (calling my function disconnectFromService), i always get this exception. Service is…
Johnny
  • 193
  • 1
  • 1
  • 8
9
votes
1 answer

Android foreground service consistently throws "java.lang.IllegalArgumentException: Service not registered" exception

My project requires an android foreground service to run continuously (even after the application is destroyed). To this effect I have the following code snippets: build.gradle implementation fileTree(dir: 'libs', include: ['*.jar']) //noinspection…
9
votes
3 answers

RuntimeException on app load only in production release

I am having an issue with an app I am creating. Basically the app will crash the first time you try to open it and then it will be alright after that. The confusing part is it only happens when you download the app from Google Play. If I load the…
sabo
  • 911
  • 13
  • 37
1
2 3
27 28