android studio intent pass data code example

Example 1: send variable intent

String sessionId = getIntent().getStringExtra("EXTRA_SESSION_ID");

Example 2: send variable intent

Intent intent = new Intent(getBaseContext(), SignoutActivity.class);
intent.putExtra("EXTRA_SESSION_ID", sessionId);
startActivity(intent);

Example 3: kotlin android intent pass data

//Send value from HomeActivity

val intent = Intent(this@HomeActivity,ProfileActivity::class.java)
intent.putExtra("Username","John Doe")
startActivity(intent)

//Get values in ProfileActivity

val profileName=intent.getStringExtra("Username")