vendredi 8 mai 2015

How to stop while loop after back button is hit

I have tried so many ways of solving my problem, but still no success.I have a method, which returns me a string value and I am using it to update TextView on my screen like this: outCPU.setText(getCpuInfo());

Which would be fine, but I need to update this TextView until back button was pressed.

I guess i have need a while loop which starts after activity has been created and stops after back button was pressed. This loop should be in a new thread, because:- I have to load the activity first and execute the loop in another thread so the executing won't affect main thread and loading of the activity.

As I've already said, I don't know how to do this properly even though i have spent few hours on it.

Could someone show me an example how to get this done? Thanks...!!

Aucun commentaire:

Enregistrer un commentaire