Finish all daughter threads of an Activity

Asked

Viewed 131 times

0

In my Activity I instill some controls that search server data asynchronously.

The control instance is as follows:

new controle().executar(new InterfaceRetorno(){...});

But what happens is this, if the user presses the back button I destroy Activity with the Finish() method. And that’s where the problem is, because if the interface hasn’t updated Textview yet, when it returns something and tries to update, it will give a null exeption

How do I finalize all the actions that are occurring that are daughter of this Activity?

  • Enter the code of one of these Threads.

1 answer

0

use the onDestroy method in Activity to effect process completion...although I recommend using a class called Asynctask to perform these processes.

@Override
    protected void onDestroy() {
        super.onDestroy();
        // cancelar a requisição
    }

Browser other questions tagged

You are not signed in. Login or sign up in order to post.