安卓远程服务 [英] Android Remote Service
问题描述
在远程进程中运行 Android 服务是否意味着它在不同的线程上运行?这是本地服务和远程服务之间的区别吗?
Does running an Android service in a remote process mean that it's running on a different Thread? Is that a difference between a local and remote service?
同理,通过IPC调用远程服务时,是否立即返回?还是等待操作完成?
Similarly, when calling a remote service via IPC, does it return immediately? Or does it wait for action to be done?
推荐答案
在远程进程中运行 Android 服务是否意味着它在不同的线程上运行?
Does running an Android service in a remote process mean that it's running on a different Thread?
由于线程归其进程所有,因此在单独的进程中提供服务意味着它将使用与任何其他进程使用的线程不同的线程.
Since threads are owned by their process, having a service in a separate process means it will be using threads other than those used by any other process.
这是本地服务和远程服务之间的区别吗?
Is that a difference between a local and remote service?
通常,远程服务"是由单独的应用程序提供的服务.
Typically, a "remote service" is one supplied by a separate application.
同理,通过IPC调用远程服务时,是否立即返回?还是等待操作完成?
Similarly, when calling a remote service via IPC, does it return immediately? Or does it wait for action to be done?
调用是同步的——它们必须是同步的,因为 AIDL 方法可以返回结果.当客户端通过 AIDL 定义的方法调用服务时,客户端会阻塞直到服务返回,无论双方碰巧使用的是哪个进程或线程.
Calls are synchronous -- they have to be, since AIDL methods can return results. When a client calls a service via an AIDL-defined method, the client blocks until the service returns, regardless of what process or thread either side happens to be using.
这篇关于安卓远程服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!