I have Acvtivity that creates view and mediaplayer. I want to use OnCompletion event to make that view clickable. But it throws exception, I don't 开发者_开发问答know why. Probably, mediaplayer runs in another thread and cannot access elements from main ui thread? Thank you for any information
Use Activity.runOnUiThread()
to make sure your code is running in the correct thread.
//assuming this code is within an Activity class, you can
//access this function directly. Otherwise you must
//have a reference to an Activity object
this.runOnUiThread(new Runnable()
{
public void run()
{
//perform UI-thread only tasks
}
});
精彩评论