Skip to content

Instantly share code, notes, and snippets.

@magdamiu
Created May 12, 2020 22:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save magdamiu/fd4a9024cfec6e8dd7874f4d3e11f987 to your computer and use it in GitHub Desktop.
Save magdamiu/fd4a9024cfec6e8dd7874f4d3e11f987 to your computer and use it in GitHub Desktop.
Bundle - send and receive data
// send data
String message = "just a text";
Intent lunchReceiveTextActivity = new Intent(BundleSampleActivity.this, ReceiveTextActivity.class);
lunchReceiveTextActivity.putExtra(BundleSampleActivity.TEXT, message);
startActivity(lunchReceiveTextActivity);
// get data
Bundle bundle = getIntent().getExtras();
if(bundle != null) {
String message = intent.getStringExtra(SendTextActivity.CAROL);
if (!message.isEmpty()) {
// use the received message
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment