-1

I have created an app with 5 activities where the user will input numbers into 4 edit text fields on each activity and move between them in a sequence with a "Next" Button.

I want to be able to save/gather all of the user inputs across the activities and calculate a maths formula to be displayed in text view on another activity .

What can be recommended to do this?

Thanks in advance!

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
CKB493
  • 3
  • 4

1 Answers1

0

Use putExtra to pass the numbers to the next activity

Activity A on click of next button

           next.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {

                        Intent i = new Intent(getActivity(), BActivity.class);
                        i.putExtra("A1", String.valueOf(firstnumber));
                        i.putExtra("A2", String.valueOf(secondnumber));
                        i.putExtra("A3", String.valueOf(thirdnumber));
                        i.putExtra("A4", String.valueOf(fourthnumber));
                        startActivity(i);

                }
            });

Activity B in onCreate

Bundle extras = getIntent().getExtras();

String firstnumber = extras.getString("A1");
String secondnumber = extras.getString("A2");
String thirdnumber = extras.getString("A3");
String fourthnumber = extras.getString("A4");
int A = Integer.valueOf(firstnumber);
int B = Integer.valueOf(secondnumber);
int C = Integer.valueOf(thirdnumber);
int D = Integer.valueOf(fourthnumber);

Then keep sending the numbers to the next activity.

Callie
  • 11
  • 4