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(\
Pass the intent with value on First Activity:
Intent intent = new Intent(FirstActivity.this, SecondActivity.class);
intent.putExtra("uid", uid.toString());
intent.putExtra("pwd", pwd.toString());
startActivity(intent);
Receive intent on second Activity;-
Intent intent = getIntent();
String user = intent.getStringExtra("uid");
String pass = intent.getStringExtra("pwd");
We use generally two method in intent to send the value and to get the value.
For sending the value we will use intent.putExtra("key", Value);
and during receive intent on another activity we will use intent.getStringExtra("key");
to get the intent data as String
or use some other available method to get other types of data (Integer
, Boolean
, etc.).
The key may be any keyword to identify the value means that what value you are sharing.
Hope it will work for you.