Home > Net >  Function for androidstudio java
Function for androidstudio java

Time:02-10

Which function is called when an app is killed by keeping it in recent list for a long time.

I am not asking that app is killed by swiping app from recent file.

CodePudding user response:

There is no such function in Android.

When user closes the app, the process is terminated with no notice. Even Activity's onDestroy method is not guaranteed to be called. Only when you explicitly call finish().

If you use ViewModel that is tied to the starting Activity's lifecycle, you can try to use onCleared() method, which is called always when ViewModel is no longer used and will be destroyed. See: https://developer.android.com/topic/libraries/architecture/viewmodel

  •  Tags:  
  • Related