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");
}

Popular posts from this blog

SAP CPI - Loop Process Call with SuccessFactor (oData V2)

Setting IntelliJ IDEA to run Groovy Script

C# - BASE64 to Image