android-service-binding

Does Binder have to be an inner class?

百般思念 提交于 2020-01-25 20:25:07
问题 I am reading upon Android Bound service, http://developer.android.com/guide/components/bound-services.html public class LocalService extends Service { // Binder given to clients private final IBinder mBinder = new LocalBinder(); // Random number generator private final Random mGenerator = new Random(); /** * Class used for the client Binder. Because we know this service always * runs in the same process as its clients, we don't need to deal with IPC. */ public class LocalBinder extends Binder

How to start the NotificationListenerService on Android

旧城冷巷雨未停 提交于 2020-01-24 09:26:11
问题 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 intents look like? Can someone show me the syntax of this? Check out one of the service implementations I am studying: public class NLService extends NotificationListenerService { Context context; @Override public void onCreate() { super.onCreate();

Sending data to a bound service

岁酱吖の 提交于 2020-01-03 04:48:15
问题 I have a service that is started. In addition, other components can bind to the service. When a component binds to the service, it has new parameters it needs to deliver to the service. Is it possible to force onBind to be called each time a caller needs to bind (so as to deliver new data through intent)? And if so, is the additional overhead of calling onBind each time significant? BTW, this is a local service where I extend Binder instead of using Messenger. 回答1: Few points to consider: 1)

Binding and starting a service when application starts

*爱你&永不变心* 提交于 2020-01-03 03:04:11
问题 I have a service in Android that encapsulates a framework that has a start method. The service boils down to something like this, many things omitted: public class MyService extends Service { private IBinder thisBinder; public MyService(){ thisBinder = new LocalBinder(); } @Override public IBinder onBind(Intent intent) { return thisBinder; } public void start(Map<String, Object> options) { getDriverManager().start(options); } } I also have a bridging class that makes calls to the service:

How to access instance of MediaBrowserServiceCompat service?

岁酱吖の 提交于 2020-01-01 19:42:33
问题 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 extends Binder { public MyService getService() { return MyService.this; } private final MyBinder binder = new MyBinder(); @Override public IBinder onBind(Intent intent) { return binder; } public void doMagic() { // <-- How to call this from

update listview in my activity from service android

亡梦爱人 提交于 2020-01-01 05:12:28
问题 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 update in my activity without rebuild the again only i need to refresh the list view. i found it will be manipulated using iBinder , But i don't how to use it. Can any one suggest me with some examples of code . referred pages 回答1: You should use a

MediaBrowserServiceCompat unable to bind to service [closed]

百般思念 提交于 2019-12-24 09:12:48
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 3 years ago . My code is very simple, i just want to bind to the music service using MediaBrowserServiceCompat, actually i have a bigger program with the same problem so i tried to make a smaller one without all the unimportant parts and i get the following error: 08-27 11:31:30.848 12214-12214/com.example.android.newcheck E

Context error of custom system service

依然范特西╮ 提交于 2019-12-24 08:29:57
问题 I have created a system service that communicates with a zigbee device. Updated APIs and created system.img and flashed on the device and made custom SDK for android programming. In the Mainactivity class, try { ZigbeeManager zm = (ZigbeeManager) getSystemService(Context.ZIGBEE_SERVICE); zm.write("Hello World!\r"); } catch (Exception ex) { Log.d(TAG, "Error in Zigbee Service: " + ex.toString()); } I am getting an error over the words "Context.ZIGBEE_SERVICE". It says "Must be one of : list of

Android Mosby MVI bind to service in presenter

半腔热情 提交于 2019-12-22 17:22:13
问题 I am creating a small app using Mosby. The app has a service which I want to bind to. I guess the correct place to do this is in the presenter. But I can't really figure out how to do it. What I want to archive is when the service is bound I want to call a method on it and push that value to the view, so that the state right now is correct. When the service sends updates on the event bus I want to push that to the view as well. I have found some example on the later part, but nothing about

Android Mosby MVI bind to service in presenter

徘徊边缘 提交于 2019-12-22 17:22:11
问题 I am creating a small app using Mosby. The app has a service which I want to bind to. I guess the correct place to do this is in the presenter. But I can't really figure out how to do it. What I want to archive is when the service is bound I want to call a method on it and push that value to the view, so that the state right now is correct. When the service sends updates on the event bus I want to push that to the view as well. I have found some example on the later part, but nothing about