Contents
We can send the data using putExtra() method from one activity and get the data from the second activity using getStringExtra() methods. Example: In this Example, one EditText is used to input the text. This text is sent to the second activity when the “Send” button is clicked.
How send data from one activity to another in Android?
passing the custom Object in activity,
- Pass it to the activity, Intent intent = new Intent(getActivity(), Activity. class); intent. putExtra(“list”, (Serializable) mainData. getData(). getFeaturedProduct()); getActivity(). …
- And get it. ((List) getIntent(). getExtras(). getSerializable(“list”))
30 сент. 2017 г.
How do you share data between activities?
Send data inside intents
putExtra(“some_key”, value); intent. putExtra(“some_other_key”, “a value”); startActivity(intent); On the second activity: Bundle bundle = getIntent().