Question

I have two activities A & B in my app. I've learned how to save and restore all data whenever config change happens. In my app, a user has to go to activity B from A (all the data is in B).

Now, whenever screen rotation happens, app restarts and goes to activity A.

How can I know about the last activity before screen rotation happened so that I can directly open the same activity and let my user continue ?

Was it helpful?

Solution

Try this it might help you.

Paste this code second activity. This method is called when screen orientation change.

For ex: portrait to landscape or vice versa.

Take one variable and manipulate that variable value to know on previous activity.

@Override
public void onConfigurationChanged(Configuration newConfig) {
   super.onConfigurationChanged(newConfig);
   //Write Logic for start the same activity like and restore the data.
   startActivity(new Intent(context,SecondActivity.class));
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top