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 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