Hi,

Quite often when I launch an Activity using startActivityForResult I need to store some context data that will be needed in my onActivityResult implementation. (e.g., a reference to some in memory data that will be modified after the child activity finishes). The data in question is transient by nature so it's not already stored in a db somewhere.

Up until now I was simply storing data in a field of the parent activity, however this isn't reliable as this wont survive a restart of the parent activity (e.g., when a config change happens). In some of my code I've handled this by passing a PendingIntent (created using Activity#createPrendingResult) to the child activity where I stored all the context data in the intent extras. This works for my own code, but is not generally usable since most of the platform provided activities don't support this way of working. The only other alternative I've been able to come up with is storing the data in a database or making sure I store the fields when Activity#onSaveInstanceState.

All the options I listed above feel like more work than I would like to do for something that seems rather common. Does anyone have a simpler solution to this problem or is there a recommended best practice that I can follow?

Regards,

Pepijn

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to