Can I pass by reference object between activity in Android , How ?
Thankyou
Can I pass by reference object between activity in Android , How ?
Thankyou
You should have googled it.
You can use these examples if your objects implements Parcelable or Serializable. Unfortunaley it is not possible to send an object be reference. You can get around this problem be sending te object back:
returning the object:
Intent result = new Intent();
result.putExtra("NAME", myEditedObject);
setIntent(result);
setResult(Activity.RESULT_OK);
finish();
reading the returned object:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// Check which request we're responding to
if (requestCode == MY_REQUEST_CODE) {
// Make sure the request was successful
if (resultCode == RESULT_OK) {
Bundle b = this.getIntent().getExtras();
if (b != null)
myObject= (MyObject) b.getParcelable(STRING_NAME);
}
}
}
If your object implements Parcelable or Serializable, then the answer is yes. Just put the object in the intent that you're going to use to display the activity.