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

Why to use Android Bound Service?

I am curious to know why would you use Bound Service for 2 way interaction between Activity and Service when you can do the same kind of interaction with Started Service using local broadcasts and receivers defined in both Activity and Service It…
bitmult
  • 108
  • 1
  • 8
8
votes
1 answer

Bound service leaks memory

I wrote a basic bound service based on the Android documentation, but LeakCanary is telling me the service is leaking. Is there a leak or have I misconfigured LeakCanary? How can I write a bound service that does not leak? The Code class…
Enrico
  • 10,377
  • 8
  • 44
  • 55
8
votes
0 answers

how to start android-TREBLE compatible vendor java service from /vendor/app

In my Android-O device, below two background services communicating each other though AIDL. Native/c++ android service Starts through init rc Runs with system linux-user Deployed in /system partition, eg, /system/bin/nat binary. Java Service from…
8
votes
4 answers

How to sync Toggle Button State with Foreground Service?

I have a Foreground Service which I start and stop with a Toggle Button in an Activity. To keep track if the Service is running or not I have used a variable which I store in SharedPreference. Here is the flow When a user enables toggle…
8
votes
1 answer

Android: Binding to a remote service

I'm building a remote service and a client application targetted at API 24 executing on a Nexus 6P device. I have a remote service that automatically starts at boot. Here are the code fragments: Remote Service Manifest
pfp
  • 125
  • 1
  • 5
8
votes
2 answers

AIDL service not connecting after bindService()

I am trying to develop a setup of 2 applications (service app + client app) using AIDL. I have currently a setup of 3 modules: android-agent-framework (android library module holding only the AIDL file) android-agent (the…
TyrManuZ
  • 2,039
  • 1
  • 14
  • 23
8
votes
1 answer

android remote service within the app vs separate app

I'm trying to figure out the pros and cons of writing an android remote service as a part of my client app (using android:process=":remote") vs making it a separate service app. In both the cases, the service would be running in its own separate…
pree
  • 2,297
  • 6
  • 37
  • 55
8
votes
1 answer

How to handle the necessity of interprocess communication in my Android application?

My application requires me to periodically do the following: Send periodic heartbeat information to a server, once per 15 seconds Take periodic screen captures and send them to a server, once per 60 seconds Send message to and poll the server for…
Ryan
  • 6,756
  • 13
  • 49
  • 68
7
votes
1 answer

binding a service to multiple activities

My service is correctly binded to my first activity but when I try to bind it to a second activity it does not work Here is the code of onresume and on pause of my first activity @Override protected void onResume() { super.onResume(); …
sabrina2020
  • 2,102
  • 3
  • 25
  • 54
7
votes
3 answers

update listview in my activity from service android

I having 2 classes , 1.Activity class 2.Service class I need to update my list view in my activity,when service got any updates. Actually i trying like an chat application , My services always checking my db and if it got any new string , i need to…
GK_
  • 1,212
  • 1
  • 12
  • 26
6
votes
2 answers

App isn't killed when removed from recent tasks when using service

First of all, this question is NOT about how I can prevent the app from being killed. Actually I want it to be killed. Now the problem. My application connects to a BLE devices and I want the connection to be maintained when the app is in the…
Mohru
  • 725
  • 1
  • 7
  • 17
6
votes
2 answers

How to access instance of MediaBrowserServiceCompat service?

I'm surprisingly struggling to get hold of the instance of a service which is derived from MediaBrowserServiceCompat. For a typical service, to achieve that, a local binder is used class MyService extends MediaBrowserServiceCompat { class MyBinder…
6
votes
1 answer

How to start the NotificationListenerService on Android

I would like to access notifications on a Android phone by using the NotificationListenerService. I checked lots of tutorials but I can't find where they call the service. Should I use bindService or startService on MainActivity? How should the…
6
votes
1 answer

Do I need to perfectly pair bindService / unbindService calls?

It appears from all the code examples that we only want to invoke #unbindService (on the same context), if we have invoked #bindService, which is accomplished via a boolean check. But there are no similar checks in the #bindService call -- i.e. we…
Creos
  • 2,445
  • 3
  • 27
  • 45
6
votes
2 answers

Is there a need to have one ServiceConnection per each Service bind?

I have several Android Services that I want to bind to in my Activity, so I can monitor several actions from the user. To be able to bind every Service, and I will have several, do I need several private ServiceConnections in my activity like the…
1
2
3
27 28