Today we learnt about Forward Passing and Backward Passing using intent and intent bundle.
In forward pass you just need to use the putExtra Method to pass the data across multiple program screens.
In forward pass you just need to use the putExtra Method to pass the data across multiple program screens.
The putExtra method accepts many kinds of data, such as String, int, float, byte etc etc .. we can use intent bundle like:
Intent intent = new Intent(this, OtherActivity.class);
intent.putExtra(OtherActivity.KEY_EXTRA, yourDataObject);
startActivity(intent);
Bakward Passing:
Activity 1 :Intent i = new Intent(this, Activity2.class);
startActivityForResult(i, 1);
Activity 2: Intent intent = new Intent();
intent.putExtra("editTextValue", "value_here")
setResult(RESULT_OK, intent);
finish();
Comments
Post a Comment