Reputation: 11
Hi I´m just starting to learn how to use Android Studio. And I want to try to send the values of the choices the user makes from one activity to the other.
Upvotes: 1
Views: 61
Reputation: 785
1.Change this to arraylist
String[] mackor_names = {
"Tonfisk Macka 30:-",
"Skagen Macka 35:-",
"Kyckling Macka 35:-",
"Curryröra Macka 30:-",
"Ost o Kalkon Macka 25:-",
"Köttbulle Macka 25:-",
"Falafel Macka 20:-"
};
ArrayList<String> list = new ArrayList<>();
list.add("Tonfisk Macka 30:-");
list.add("Skagen Macka 35:-"); ......
2.and then use
intent.putStringArrayListExtra("test",list);
3.and to get values
Intent intent=getIntent();
ArrayList<String> test = intent.getStringArrayListExtra("test");
Upvotes: 1
Reputation: 16
//Create the bundle
Bundle bundle = new Bundle();
//Add your data from getFactualResults method to bundle
bundle.putString("VENUE_NAME", venueName);
//Add the bundle to the intent
i.putExtras(bundle);
Insead of array you can use bundle
Upvotes: 0
Reputation: 16
You can pass data like this(this is from SecondActivity):
Intent intent = new Intent(this, ThirdActivity.class);
intent.putExtra("EXTRA_SESSION_ID", sessionId);
startActivity(intent);
and than in ThirdActivity in onCreate method:
String sessionId = getIntent().getStringExtra("EXTRA_SESSION_ID");
Also, best practise is to have key "EXTRA_SESSION_ID" stored in public static variable so you have only one object
Upvotes: 1