Android provides saveinstancestate this work on UI. It works like this when changing the orientation of the phone while using this method. At the time orientation of all components is restored but when using saveinstancstate, it can not be restored in the application. The saveinstacestate is a reference to the bundle object that is passed into the oncreate method in Android application.
Step-By-Step Implementation
Step 1:Create a new project in Android or you can use an already created project.
or
Step 2: Create an XML file named Acitivity_main.xml.
Step 3: Acitivity_main.xml file continent Design of screen like button, text view, etc.
Step 4: Create ActivityMain.java or java in your project inside (com.my application).
Step 5: Output of above example
Happy coding!