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
0
votes
1 answer

How to avoid killing and restarting the service and process when app is swiped to right in Overview(a.k.a recent apps screen) screen?

I am seeing my app in the following screen https://i.stack.imgur.com/BbqqZ.jpg If I swipe my app to the right, I notice that the process and services related to app are killed. How to avoid killing the process and services when we swipe? How to…
sofs1
  • 3,834
  • 11
  • 51
  • 89
0
votes
2 answers

android -implications of creating an instance of a Service class

I inherited some android code and i notice there is a class extending Service but its not declared in the manifest. I find this disturbing. i investigated further and i see that the service is not declared in the manifest yet it still works…
j2emanue
  • 60,549
  • 65
  • 286
  • 456
0
votes
1 answer

ArrayList is arriving empty in Android's handleMessage() method

In a service I'm populating an ArrayList, which I then return to the calling activity: In service (here, resultArrayList contains items and is of class ArrayList): public class DataFetchService extends BaseService { @Override …
zundi
  • 2,361
  • 1
  • 28
  • 45
0
votes
1 answer

onCharacteristicChanged is not called in Android BLE GATT servcies

I am trying to receive the data from BLE device in my app. i could able to connect the BLE device successfully with my app and i am able to find the services provided by the BLE devices. I can able to write data in characteristics and able to…
0
votes
1 answer

BindService throws nullpointer, even when pointing on pure string

I'm trying to make a boundService in my app, but I cannot get any result back, no matter what it just returns null. I can see in debugging that the code runs fine in my service, but I suspect that my activity is too fast, so when it has called the…
0
votes
0 answers

Running aidl service in background?

I have a aidl process through which i make connection to my server and perform login, But the problem is when i close the application i am unbinding the service in onDestroy() callback of activity, so here my server connection gets disconnected and…
0
votes
1 answer

Strategy pattern and Android Service/UI Messaging communication

I have an Android bound service that communicates with activities with Messenger. My service capture new messages through a handler like this: @Override public void handleMessage(Message msg) { switch (msg.what) { case…
0
votes
3 answers

Android request permission doesn't work for notifications permissions

Why this code works: ActivityCompat.requestPermissions(thisActivity, new String[]{Manifest.permission.READ_CONTACTS}, 666); ## In the manifest and this…
0
votes
2 answers

Could I call a function of service from another service in Android?

I have a function in a service as follows: public class ServiceA extends Service { @Override public void onCreate() { super.onCreate(); Log.d(TAG, "onCreate"); } @Override public int onStartCommand(Intent intent,…
user3051460
  • 1,455
  • 22
  • 58
0
votes
1 answer

How to unbind a service when the application is destroyed

I want to start a service when the users open my application, some of my activities need to bind the service, and when the users close my application, I stop the service. The question is where can I stop the service. I want my service work when my…
L. Swifter
  • 3,179
  • 28
  • 52
0
votes
1 answer

Getting "Activity has leaked ServiceConnection" despite unbinding it in onDestroy or onPause

I made a custom bound service that I run using startService in my MainActivity, then bind to it. I do the same within one of the other activities. But whenever I quit that activity (and the service keeps running as it was intended to) or even close…
0
votes
2 answers

Android Sensor Shake in the background

I'm trying to follow a tutorial about sensor. It works fine with an activity. However, I want this to work in the background when the phone is locked. What's the best way to do that? Here's the link to the tutorial…
Julia
  • 1,207
  • 4
  • 29
  • 47
0
votes
1 answer

Can I instantiate a bound service class in android by calling new?

Normal way of using a bound service: private ServiceConnection musicConnection = new ServiceConnection() { public void onServiceConnected(ComponentName name, IBinder service) { MusicBinder binder = (MusicBinder)service; //get service …
Kishan Kumar
  • 685
  • 1
  • 5
  • 17
0
votes
0 answers

Android service active even after unbind called

In my android app, parent activity launch a service on a user action using bindService(intent, mConnection, Context.BIND_AUTO_CREATE); In service I receive location updates(implementing LocationListener). I also provide a STOP button on UI which…
Mandroid
  • 6,200
  • 12
  • 64
  • 134
0
votes
5 answers

How to keep service alive even after activity destroyed?

Here i am running a service for music play back. This code snippet is in my onStart() method of my Activity if(musicServiceStartIntent == null) { musicServiceStartIntent = new Intent(this, MusicService.class); …
saa
  • 1,538
  • 2
  • 17
  • 35