Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Transfer data from one Activity to Another Activity Using Intents

Tags:

I would like to be able to transfer data from one activity to another activity. How can this be done?

like image 992
user555910 Avatar asked Feb 11 '11 10:02

user555910


People also ask

How do you pass data from one activity to another activity using intent?

Using Intents This example demonstrate about How to send data from one activity to another in Android using intent. Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main. xml.

How do I transfer data from one activity to another second activity?

We can send the data using putExtra() method from one activity and get the data from the second activity using the getStringExtra() method.

How pass data from intent to intent?

The easiest way to do this would be to pass the session id to the signout activity in the Intent you're using to start the activity: Intent intent = new Intent(getBaseContext(), SignoutActivity. class); intent. putExtra("EXTRA_SESSION_ID", sessionId); startActivity(intent);


1 Answers

Through the below code we can send the values between activities

use the below code in parent activity

Intent myintent=new Intent(Info.this, GraphDiag.class).putExtra("<StringName>", value); startActivity(myintent); 

use the below code in child activity

String s= getIntent().getStringExtra(<StringName>); 
like image 108
Pinki Avatar answered Oct 01 '22 11:10

Pinki