I sent data to Intent from one activity to another.
Intent i=new Intent(context,SendMessage.class);
i.putExtra("id", user.getUserAccountId()+"");
i.putExtra("name", user.getUserFullName());
context.startActivity(i);
I like what I sent, but how do I receive it??
android android-intent
You can use the getIntent()
method in the activity of receiving data.
Intent intent = getIntent();
In the example you gave me, I sent it with ID and name
intent.getStringExtra(string name)
where putExtra(name, data);
If you put the string corresponding to the first factor of putExtra together, you can get the value you put in the second factor.
String id = intent.getStringExtra("id");
String name = intent.getStringExtra("name");
© 2024 OneMinuteCode. All rights reserved.