1

in my app, I perform an action onDestroy. But I don't want the action if the app is rotated. I used onSaveInstanceState to save variables when the app is rotated and check if saveInstanceState != null onCreate.

I have not seen anyone check for saveInstanceState onDestroy, is it okay to do that?

Anga
  • 2,450
  • 2
  • 24
  • 30
  • `onDestoy()` not meant to call each time . You should do it in `onSaveInstanceState`.. – ADM Apr 26 '18 at 15:43
  • Take a read [Activity OnDestroy never called?](https://stackoverflow.com/questions/4449955/activity-ondestroy-never-called). – ADM Apr 26 '18 at 16:00
  • Possible duplicates https://stackoverflow.com/questions/20831826/when-exactly-are-onsaveinstancestate-and-onrestoreinstancestate-called – Badr Apr 26 '18 at 16:37

1 Answers1

0

There is no guarantee to everytime onDestroy method called.

onSaveInstanceState() was called immediately before onPause() as per documentation

so it not okey to check for saveInstanceState on Destroy.

GParekar
  • 1,209
  • 1
  • 8
  • 15