后台服务可连续更新UI [英] Background service to update UI continuously

查看:67
本文介绍了后台服务可连续更新UI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想运行一个服务,该服务从外部传感器获取数据并<秒>每秒更新一次用户界面,而不会阻塞主线程.实现此目标的最有效可能性是什么?线程,IntentService,服务?还是其他?

I would like to run a service that gets data from an external sensor and updates the UI every second without blocking the main thread. What is the most efficient possibility to make it? Thread, IntentService, Service? Or anyting else?

提前谢谢!

推荐答案

如果要定期更新UI,并且活动必须访问该服务方法,则应使用绑定服务.

You should use a binded service if you want to update UI regularly and the activity has to access the service method.

服务与IntentService

在此链接中检查绑定服务在android中的工作方式

Check how binded service in android works in this link

这篇关于后台服务可连续更新UI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆