0

I have Next Button in one activity. This button will be used to move to the next activity i.e. second activity. The same button will also be used to send some calculated data from one activity to the last activity. There are around 15 activities. So, it will be displayed on 15th activity.

My activities are destroying previous data so I want to send all the activities data to last activity. At the same time, keep moving to the next activity through the same button.

I know to use Intent for moving to the next activity. I can pass the data also to the next activity. But, I only know to start the intent of one activity. Can I add another intent in the same activity of the same button?

thebeginning
  • 31
  • 1
  • 5
  • I did not really understand what you want to achieve, do you have some code to show us? For me it seems that is just the case to send data from one activity to another – Shermano Jun 19 '19 at 12:21
  • @Shermano Activity 1, Activity 2, ....,Activity 15. Next Button is there on Activity 1,Activity 2, and so on. From Activity 1 Next Button, I use intent to move to Activity 2(i.e. Activity 2 gets opened) But now, I want to use same button i.e. Next Button of Activity 1 to use intent and send some data to Activity 15. – thebeginning Jun 19 '19 at 12:29
  • @Shermano This moves to next page. startActivity(new Intent(one.this, two.class)); I want to write on the next line, startActivity(new Intent(one.this, fifteen.class)); Will this work?If not then is there any alternative method to achieve this? – thebeginning Jun 19 '19 at 12:31
  • Well this will open Activity 15 and Activity 2 at the same time, activity 15 will be on top and activity 2 on the back stack, that is what you want to achieve? – Shermano Jun 19 '19 at 12:35
  • @Shermano Ohh :( No. I wanted to show activity 2 immediately after activity one. And send some data of activity 1 to activity 15 for usage purpose in activity 15. What is the alternative method to achieve this on activity 15? – thebeginning Jun 19 '19 at 12:38
  • just send the data to activity 2 first, then you keep sending throught all activities util you reach the activity 15, then you'll have the data you want! got it? – Shermano Jun 19 '19 at 12:45
  • @Shermano I already did that technique. Doing it destroys the data at the end when the user uses the previous button many times. – thebeginning Jun 19 '19 at 12:50
  • hmm ok, you probably need to cache your file on SharedPreferences or on a local database. It's possible to control that throught the previous button overriding onBackButton, but idk if it's a good way to handle this, i woul stick with database or shared preferences – Shermano Jun 19 '19 at 12:57
  • Yes, I thought of doing through shared preferences but I am still a beginner. I don't know how to store string results or textview values of each activity to sharedpreferences and reuse it in the last activity. – thebeginning Jun 19 '19 at 13:13
  • 1
    check this out: https://stackoverflow.com/a/12074219/783238 – Shermano Jun 19 '19 at 13:16

0 Answers0