Finalize all the child threads of an activity

0

In my activity I instantiate some controls that search server data asynchronously.

The control instance is as follows:

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

But what happens is the following, if the user hit the back button I destroy the activity with the finish () method. And that's where the problem is, because if the interface has not updated the TextView yet, when it returns something and tries to update, it will give a null exeption

How do I finish all the actions that are occurring that are the daughter of this activity?

    
asked by anonymous 10.11.2016 / 15:06

1 answer

0

Use the onDestroy method in activity to perform process terminations ... although I recommend using a class called AsyncTask to perform these processes.

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