calling function when exiting the app

626 Views Asked by At

I built an app that plays songs, and while the app runs I am saving information about the songs that the user heard (Did he heard the song or forwarded it).

I want to call a function when the user closes the app (full close, not to be in background), the function connects to the server and writes there the info it got (the server part works good and it is not the problem here).

I tried to put the code that calls the server in onDestroy() but it is not working (I guess onDestroy() is not called at all). when I tried to put the call to the server in onStop() the app crashed when the app was in background.

Any suggestions?

1

There are 1 best solutions below

0
On

Solved. I jost forgot to call the super.onStop();