Wednesday, August 31, 2011

Re: [android-developers] Update UI from Service

On Wed, Aug 31, 2011 at 5:05 AM, Chirag Raval
<chirag.android.developer@gmail.com> wrote:
> Can any one help me to update UI from Service ?
>
> Here in my application i created one service, from my service i want
> to update a textview which is in my Main Activity ?
>
> How can i change that textview's value from my service ?

You send a message from the service to the activity, and the activity
updates the TextView. Whether you do this via binding and the listener
pattern, or ordered broadcasts
(http://commonsware.com/blog/2010/08/11/activity-notification-ordered-broadcast.html),
or a Messenger object passed as an Intent extra, or a PendingIntent
from createPendingResult(), or something else, is up to you and would
depend a bit on the service in question.

--
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

Warescription: Three Android Books, Plus Updates, One Low Price!

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment