来自服务的Android更新活动UI我有一项一直在检查新任务的服务。如果有新任务,我希望刷新ActivityUI以显示该信息。我确实找到了https:/github.com/CommonsGuy/CW-andtutorials/tree/master/18-LocalService/这个例子。这是个好办法吗?还有其他的例子吗?
3 回答
湖上湖
TA贡献2003条经验 获得超2个赞
IntentFilter filter = new IntentFilter();
filter.addAction("com.hello.action");
updateUIReciver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
//UI update here
}
};
registerReceiver(updateUIReciver,filter);Intent local = new Intent();local.setAction("com.hello.action");this.sendBroadcast(local);unregisterReceiver(updateUIReciver);
- 3 回答
- 0 关注
- 530 浏览
添加回答
举报
0/150
提交
取消
