Search code examples
androidcanvascolorspaintondestroy

onDestroy() is getting called after onPause()


I am implementing paint Application. My problem is that when i color on object.After some times screen goes to sleep.When i awake the screen, my old paint lost. I find out issue its calling OnDestroy after Onpause automatically so it clears canvas. How to stop calling Ondestroy automatically.


Solution

  • You shouldn't try to circumvent Android's activity workflow and memory management by avoiding onDestroy() (in fact, I think you can't).

    Use onSaveInstanceState(Bundle) to store your current state and restore it on onCreate(Bundle), if a Bundle is provided.