hi there!
in my android app i have an ui-update-thread that keeps all my views up-to-date.
protected Thread UIUpdateThread = new Thread()
{
@Override
public void run()
{
while(true)
{
query_some_data_from_service(); // gets some "fresh" data from a service
UIUpdateHandler.sendEmptyMessage(0); // will update all ui elements with the new values
sleep(1234);
}
}
};
i start this thread in onCreate() with
UIUpdateThread.start();
and everything works just fine :) when i leave the activity (e.g. because i switch to another activity) i call
UIUpdateThread.interrupt();
within onStop() to prevent the thread from running all the time. if i dont do this, it would keep running even if i close the app !?!?!!
problem is: how do i bring this thread back to life when returning from some other activity to this one? run() doesnt work, calling the initial start() in some other method like onResume() crashes the app.
i already tried a lot of things, but nothing seems to work :(