How can I send data from one activity (intent) to another?
I use this code to send data:
Intent i=new Intent(context,SendMessage.class);
i.putExtra("id", user.getUserAccountId()+"");
i.putExtra("name", user.getUserFullName());
context.startActivity(i);
Add-up
Set Data
Get Data
Instead of initializing another new Intent to receive the data, just do this:
If you are trying to get extra data in fragments then you can try using :
Place data using:
Get data using:
Kotlin
First Activity
Second Activity
Suggestion
Always put keys in constant file for more managed way.
If used in a FragmentActivity, try this:
The first page extends FragmentActivity
In the fragment, you just need to call
getActivity()
first,The second page extends Fragment: