Skip to content

Instantly share code, notes, and snippets.

@gvr23
Created January 13, 2018 01:59
Show Gist options
  • Save gvr23/5aa05041d358b49e88b0b8a89d59c5a6 to your computer and use it in GitHub Desktop.
Save gvr23/5aa05041d358b49e88b0b8a89d59c5a6 to your computer and use it in GitHub Desktop.
maneras de como enviar data consreializable
ANDROID
==================================================================================================================================
código para enviar un intent y estar a la espera de su regreso
==================================================================================================================================
Intent intent = new Intent(getContext(), DocumentoClienteActivity.class);
startActivityForResult(intent, DOCUMENT_CODE);
==================================================================================================================================
código para enviar de regreso el objeto
==================================================================================================================================
Bundle bundle = new Bundle();
Intent intent = new Intent();
bundle.putSerializable("newDocument", getTheDocument());
intent.putExtras(bundle);
setResult(RESULT_OK, intent);
finish();
==================================================================================================================================
esperando al resultado del otro activity, desde un fragmento
==================================================================================================================================
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == DOCUMENT_CODE && resultCode == RESULT_OK) {
DocumentoBean newDocument = (DocumentoBean) data.getSerializableExtra("newDocument");
mAdapter.addItem(newDocument);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment