Created
July 7, 2021 11:22
-
-
Save AkaashSaini/b17d42621d013f4aba32792d53a46b98 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Passing Data from one activity to other | |
Use following code in first activity | |
Intent intent=new Intent(Main.this,second.class); | |
Intent.putExtra(“val”, t1.getText().toString()); //parameter, value | |
startActivity(intent) | |
putExtra() – It is used to store parameter with value in intent. | |
Write following code in second activity | |
TextView tv=(TextView) findViewById(R.layout.tv1); | |
Tv.setText(getIntent().getExtras().getString(“val”)); | |
getIntent() – It is used to find recent applied intent. It is member function of Activity class. | |
getExtras() – It is member of Intent class and used to grab parameters from intent. | |
getString() – It is used to fetch value of parameter. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment