Skip to content

Instantly share code, notes, and snippets.

@MohammadSamandari
Created April 2, 2019 20:53
Show Gist options
  • Select an option

  • Save MohammadSamandari/2fa271688d7dc42f92f2d4863df01e40 to your computer and use it in GitHub Desktop.

Select an option

Save MohammadSamandari/2fa271688d7dc42f92f2d4863df01e40 to your computer and use it in GitHub Desktop.
intent - Multiple Activity - Moving from activity to another one
// Defining the second activity for moving to.
Intent intent = new Intent(getApplicationContext(), SecondActivity.class);
// putting and extra into an intent so that on the other activity could be recieved.
intent.putExtra("editText", editText.getText().toString());
// Starting the second activity
startActivity(intent);
// On the Second Activity: how te recieve the intent that opened this activity.
Intent intent=getIntent();
// How to extract the extra that has been put in the intent before starting the activity.
intent.getStringExtra("editText");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment