Run Android method when application quits

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 exits. I looked at how to do something when the application terminates and I found the onStop and onDestroy methods, but I do not know if I'm doing it right.

  public void onStop(Bundle savedInstanceState)
{
    metodo
}

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

I call the download activity inside the onCreate method and it works fine

    
asked by anonymous 09.03.2016 / 18:00

1 answer

1

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

To ensure the file is uploaded do it in onPause() .

Note that the onPause() method is also called when Activity changes to background '(no longer visible).

For more information, see Activity .Lifecycle

    
09.03.2016 / 19:25