Good day. The application has two activities and a transition between them takes place in both directions. Both activities use the same activity_main.xml markup file. I create it like this:
First activity (MainActivity.java):
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); final Intent toOfflineMode = new Intent(MainActivity.this, OfflineActivity.class); ..// And the second activation (OfflineActivity.java):
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); final Intent toOnlineMode = new Intent(OfflineActivity.this, MainActivity.class); ..// And on the corresponding buttons I hang up startActivity(toOfflineMode); and startActivity(toOnlineMode); respectively. So it turns out that if you go to the second, and then back to the first, the data that was displayed in the first is lost. One gets the feeling that every time a button is pressed, a new copy of the activation is constantly created (on the screen, a new window runs from right to left). If you press the "back" button from the second activation, the first one is returned (from left to right on the screen) and the data on it all remain as it should be. Please tell me how to make the transition between these two activities on the button without losing data in both? Thank.