Created
January 13, 2018 01:59
-
-
Save gvr23/5aa05041d358b49e88b0b8a89d59c5a6 to your computer and use it in GitHub Desktop.
maneras de como enviar data consreializable
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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