androidandroid-webviewandroid-activityandroid-websettings

How to prevent call of onDestroy() after onPause()?


In my android application I have noticed that on press of back key, after onPause() automatically, onDestroy() is getting called.

How do I prevent the application from calling onDestroy() after onPause()?

I dont want to destroy the instances after back key press.

On press of Back key, my webview object is getting destroyed. So, I am not able to access the webview again,once I press back key.

I have got two URLs. Imagine them as URL1 and URL2.

When I launch URL1 in the webview and press back key the flow is onKeyDown() -> onPause()

When I launch URL2 in the webview and press back key the flow is onKeyDown() -> onPause() -> onDestroy()

Why is there a difference in the behaviour? Has it got anything to do with cookies?

For URL1 -- cookies.isSecure=true;

For URL2 -- cookies.isSecure=false;


Solution

  • Check the declaration of your activity in Manifest. Declare it in such a manner that it can store the data when minimized.

    Activity should have the capability to restore the content.