I\'ve made a simple Android music player. I want to have a TextView that shows the current time in the song in minutes:seconds format. So the first thing I tried was to make
You have to use a handler to handle the interaction with the GUI. Specifically a thread cannot touch ANYTHING on the main thread. You do something in a thread and if you NEED something to be changed in your main thread, then you call a handler and do it there.
Specifically it would look something like this:
Thread t = new Thread(new Runnable(){
... do stuff here
Handler.postMessage(); }
Then somewhere else in your code, you do
Handler h = new Handler(){
something something... modify ui element here }
Idea its like this, thread does something, notifies the handler, the handler then takes this message and does something like update a textview on the UI thread.