Run Android method when application is terminated

Asked

Viewed 123 times

0

I have an app that downloads and sends files via ftp. When the app starts it receives a text file and would like to send the file when the application is closed. I searched on how to do something when the application closes and found the methods onStop and onDestroy, but I don’t know if I’m doing it the right way

  public void onStop(Bundle savedInstanceState)
{
    metodo
}

would be to call onStop method and inside it perform upload activity to the FTP server for example?

Because I call the download activity within the onCreate method and it works well

1 answer

1

If android destroy the process(by need to free memory for example), onDestroy() is not called and the same applies to onStop() for pre-HONEYCOMB applications..

To ensure that the file is sent do so on onPause().

Take into account that the method onPause() is also called when the Activity passes to background`(is no longer visible).

For more information see Activity . Lifecycle

Browser other questions tagged

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