Tuesday, 15 March 2011

android - How to pass Parcelable object from child to parent activity? -


I am preparing a small app that requires authentication. In my main activity I have a parcelable class called "user", which includes the user's username and password, when a user clicks on a button, a new user who passes through that user category Activity begins. It works like a charm in child activity, fill out the form to authenticate the user, then when the user clicks the back button, I would like to send the "user" class back to their main activity.

Is it possible to do this?

Start your child activity with:

  Start (Initial, 1);   

In your child activity, block your back button and add your data:

  @OnRead public at BACKPressed () {intent data = new intent (); Data.putExtra ("key", your datahare); SetResult (activity. RESULT_OK, data); Super.onBackPressed (); Get data inside internal activity inside   

and onActivityResult

  disable zero activation usage on security raid (int requestcode, integer result, Intent data) {super.onActivityResult (requestCode, resultcode, data); If (requestCode == 1 & amp; amp; amp; resultcode == activity. RESULT_OK) {DataType yourData = (DataType) data.getParcelableExtra ("key"); // whatever you want with your data}}    

No comments:

Post a Comment