WearableListenerService

WearableListenerService

本文介绍了是WearableListenerService比服务更好地与数据和消息监听器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我连我的应用程序到Android Wear的可穿戴数据层与实现DataApi.DataListener和MessageApi.MessageListener服务。该服务允许我绑定到我的活动(WearableListenerService没有)和应用程序之间交换数据和消息完美的罚款。最近我发现我的服务已得到通过这使我对我的问题,系统终止:


1.是否WearableListenerService比,这是不太可能由负载下的系统被终止上述设置好?


2.何时会WearableListenerService得到由sytstem终止,如果在所有?

I have connected my application to Android Wear's Wearable Data Layer with a service that implements DataApi.DataListener, and MessageApi.MessageListener. This service allows me bind to my activities (WearableListenerService does not) and exchange data and messages between the apps perfectly fine. Recently I noticed that my service was getting terminated by the system which leads me to my questions:

1. Is WearableListenerService better than the above setup in that it is less likely to be terminated by the system under load?

2. When does a WearableListenerService get terminated by the sytstem if at all?


**我打算有这个作为一个长期运行的服务等待事件被从Android智能手表触发

**I plan to have this as a long running service waiting for events to be triggered from an Android smartwatch

作为一个有趣的说明,我发现了AOSP问题跟踪覆盖耐磨的服务将持续多久,它是标记为过时没有答案的问题:的

As an interesting note, I found an issue on the AOSP issue tracker covering how long the wearable service will last and it is marked as obsolete without an answer: See this issue

推荐答案

您WearableListenerService的实施,将被系统调用时,有一个消息,数据层的变化,等你的应用程序,它比较快结束时,它的工作是做了(你离开范围后不久),所以使用的是你没有的主要优势有一个长期运行的后台服务(杀死资源和电池)听你的应用程序可能传入的数据。

Your implementation of WearableListenerService will be invoked by the system when there is a message, data layer changes, etc for your app and it terminates relatively quickly when its job is done (shortly after you leave the scope) so the main advantage of using that is you don't have to have a long-running background service (which kills resources and battery) to listen to possible incoming data for your app.

这篇关于是WearableListenerService比服务更好地与数据和消息监听器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-20 19:53