Android - Pass Parameter to the other activity
Use "intent.putExtra()" to pass the parameter to the next activity.
Example:
EditText _search_text = (EditText) findViewById(R.id.editTextSearchText);
Intent _intent = new Intent(this, SearchResult.class);
_intent.putExtra("search", _search_text.getText().toString().trim());
startActivity(_intent);
this.finish();
And on the "onCreate()" function of the receive activity, receive parameter by:
Example:
String _search_text;
Bundle extras = getIntent().getExtras();
if (extras != null) {
_search_text = extras.getString("search");
}
Example:
EditText _search_text = (EditText) findViewById(R.id.editTextSearchText);
Intent _intent = new Intent(this, SearchResult.class);
_intent.putExtra("search", _search_text.getText().toString().trim());
startActivity(_intent);
this.finish();
And on the "onCreate()" function of the receive activity, receive parameter by:
Example:
String _search_text;
Bundle extras = getIntent().getExtras();
if (extras != null) {
_search_text = extras.getString("search");
}