Monday, July 25, 2011

[android-developers] changing listview content in separate thread issue

I received an error saying I was changing the content of my listview
in a different thread than the main UI thread which I am. I have an
IntentService that is changing this content. Now, I've looked into
this issue a bit and decided to use a handler to perform the changes
in the main loop. Since it was difficult to get my app to crash, I am
wondering if anyone can tell me if I'm handling this properly? Here
is the part where I create the handler:

Handler handler = new
Handler(getMainLooper());
handler.post(new Runnable()
{
@Override
public void run()
{
// I do my listview content handling here
}

});

So, is this the best way to handle this? Will I have any issues
calling this handler inside of an IntentService?

--
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