开发者

android service connection... Messenger or Binder or AIDL?

开发者 https://www.devze.com 2023-02-17 15:10 出处:网络
I am getting quite confused with different opinion from diff people and the developer sitee... I am building an app in which i am开发者_开发知识库 having a service(local service) runnning... which ke

I am getting quite confused with different opinion from diff people and the developer sitee...

I am building an app in which i am开发者_开发知识库 having a service(local service) runnning... which keeps getting data updated (sockets).. i want this to get reflected in the activity each time...

which one is the most ideal way to follow ??


i think binder would be better, because messenger or aidl aims at cross-process communication.


First of all, Binder is not comparable with AIDL. They are totally different things. Binder is a IPC mechanism used in Android; while AIDL, as its name -- Android Interface Definition Language, is similar to other IDLs you might have worked with. AIDL allows you to define the programming interface that both the client and service agree upon in order to communicate with each other using Binder. App developers, however, do not use the Binder directly. Instead, they must define and interact with interfaces using AIDL.

So, your question becomes "should I use Messager or Binder?" -- My understanding is: Binder is used for inter-process communication; while Messager can be used for both inter and intra cases which do not require multi-threading. So it depends on the scenario you work on.


I think binder and aidl are the same. You have to first create a .aidl file, then you have to bind that between activity and service. Then the .aidl file will work as an interface between activity and service.

Messenger is another way.

0

精彩评论

暂无评论...
验证码 换一张
取 消