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
).
精彩评论