开发者

Updating a TextView in an Activity from a Service in Android?

I have a T开发者_如何学CextView in an Activity which I wish to update from a service. How can this be achieved?


You could use a BroadcastReceiver. An intent should be fired from a service and TextView.setText() called in the onReceive() method of the BroadcastReceiver.


Yes you can. I would suggest creating some kind of interface that the service feeds updates to. The activity will implement this interface and set itself as a 'listener' on the service (removing itself in onDestroy).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜