0

I have two activties: activity_main, activity_display

in the main_activity user enters his/her name and presses the toggle button to display. that takes the user to display_activity page where the result is displayed. if the user finds that he/she has entered the wrong info they can go back and edit.

here is where the problem starts after pressing the toggle button - display it goes to display_activity and displays but when I press "back" button I'm restarting the whole (first) main_activity again... no values are present... even the toggle button that needs to be set to "reset" is again showing "display".

should i use something else instead of

                        startActivity(intend1);

i want to resume the (first) activity main not restart everything

potato
  • 7
  • 1
  • 3
  • If you just started to work on a new project, then use fragments instead of activity. – maddy23285 Aug 23 '22 at 16:08
  • @maddy23285 There's a lot of reasons not to use Fragments, they have issues in a lot of ways. Many organizations ban them outright in their code. – Gabe Sechan Aug 23 '22 at 16:12
  • Are you implementing onSaveInstanceState and onRestoreInstanceState in your first activity? Those are your hooks to make sure state is remembered even if the activity restarts – Gabe Sechan Aug 23 '22 at 16:13

1 Answers1

0

Seems like your first activity uses results from second activity. you can use startActivityForResult. Here is a very good answer refer to it.

How to manage startActivityForResult on Android

rezwan
  • 39
  • 1
  • 4