1

我在代码中的某个地方,我只有非常有限的权限,但必须将数据发送到 android 应用程序之外。(Android系统C代码)显然我不能在那里启动一个binder服务,但我可以连接到一个已经运行的服务。因此,我的实现每秒检查服务是否可用,如果可用,它会连接并开始发送数据。这工作正常。

我的问题如下。如果我终止服务二进制/进程,客户端不知何故看不到该服务不再可用。有没有办法删除我添加的服务addService(...)?客户做getService()

4

2 回答 2

0

I could solve the problem by just periodically do a getService() again at the client side. Like this they won't see it immediately if the service is gone, but they get it at some point. Like this they can reconnect if the service is available again.

I didn't find anything to "remove" the service. But this workaround works nice.

于 2014-09-11T08:03:23.313 回答
0

没有用于删除服务句柄的 API,尽管当服务终止时,服务管理器将使用svcinfo_death(). 本机服务管理器中唯一有效的传入事务代码是SVC_MGR_GET_SERVICESVC_MGR_CHECK_SERVICESVC_MGR_ADD_SERVICESVC_MGR_LIST_SERVICES(参见service_manager.c)。

也就是说,您可能会发现将此解决方案应用于您的问题可能更有效和更可靠地决定是否需要再次调用getService()

于 2014-09-11T14:30:13.957 回答