I need to change an ImageView when a sound ends , but when I try to use a thread to use it whitout to freeze the screem the application closes;
mp = MediaPlayer.create(this, R.raw.ave_maria);
mp.start();
im = (ImageView) findViewById(R.id.imag1);
Thread thread = new Thread() {
public void run() {
while (mp.isPlaying()) {
}
im.setImageResource(R.drawable.primeiro_misterio_gozoso07);
}
};
thread.start();
You should to syncronize the code with thread UI.