Android App Development
iOS App Development
Cross Platform App Development
Hire on-demand project developers and turn your idea into working reality.
Big thanks to Webkul and his team for helping get Opencart 188.8.131.52 release ready!
Owner and Founder. Opencart
In this blog,
I have talked about activity recreating in android. And will give the some facts related to save the Activity State.
There are a few scenarios in which your activity is destroyed due to normal app behavior, such as
However, if the system destroys the activity due to system constraints, then although the actual Activity instance is gone,
The system remembers that it existed such that if the user navigates back to it, the system creates a new instance of the activity using a set of saved data that describes the state of the activity when it was destroyed. The saved data that the system uses to restore the previous state is called the “instance state” and is a collection of key-value pairs stored in a Bundle object.
Note: Your activity will be destroyed and recreated each time the user rotates the screen.
For recreating the activity, you can use the simple recreate() or startActivity(intent).
While using the recreate method works by doing,
or can use to reopen the activty by startActivity.
It was only added in API level 11. If you want to include more devices you can check the API level.
You can use both by making an if statement,
As your activity begins to stop, the system calls onSaveInstanceState() so your activity can save state information with a collection of key-value pairs.
When your activity is recreated after it was previously destroyed, you can recover your saved state from the Bundle that the system passes your activity. Both the onCreate() and onRestoreInstanceState() callback methods receive the same Bundle that contains the instance state information.
Your email address will not be published. Required fields are marked*
Save my name email and website in this browser for the next time I comment.
Be the first to comment.
Webkul is a truly trusted and supported IT Company to develop business ideas for e-commerce. They provide professional support after deploying the solution to production and be responsible to act for fixing the reported issues or system errors. We highly encourage to deal with Webkul for business development.
Enquiry or Requirement
If you have more details or questions, you can reply to the received confirmation email.