Friday, 13 July 2012

Starting an new Activity

Before starting a new activity from a current one, you need to setup the classes.

Intent display = new Intent(this, DisplayMessageActivity.class);
EditText editText = findViewById(R.id.edit_text);
String message = editText.getText().toString();
display.putExtra(EXTRA_MESSAGE, message);
startActivity(display);

From the DisplayMessageActivity then, you can get the extra like this.

Intent intent = getIntent();
String message = intent.getStringExtra(PreviousActivityClassname.EXTRA_MESSAGE);

No comments:

Post a Comment