Style-7
Style-7

Reputation: 1226

Is a callback exist when system kill process for activity?

Sometimes system can kill or terminate process of an activity. I need to save data of the activity to shared preferences.

Is any callback will call in this case?

onPause or on onSaveInstanceState not call.

Upvotes: 0

Views: 36

Answers (1)

Shreyash Pattewar
Shreyash Pattewar

Reputation: 939

When the system kills an activity's process, callbacks like onPause(), onStop(), or even onSaveInstanceState() may not always be invoked, particularly in cases of abrupt termination (e.g., low memory). However, to handle such cases and ensure your data is saved to SharedPreferences, you can rely on the ViewModel and lifecycle-aware components like ProcessLifecycleOwner.

Upvotes: 0

Related Questions