Shows how an activity can send data to its launching activity when done.y.
This can be used, for example, to implement a dialog alowing the user to
pick an e-mail address or image -- the picking activity sends the selected
data back to the originating activity when done.
The example here is composed of two activities: ReceiveResult launches
the picking activity and receives its results; SendResult allows the user
to pick something and sends the selection back to its caller. Implementing
this functionality involves the
{@link android.app.Activity#setResult setResult()} method for sending a
result and
{@link android.app.Activity#onActivityResult onActivityResult()} to
receive it.
Demo
App/Activity/Receive Result
Source files
src/com.example.android.apis/app/ReceiveResult.java |
Launches pick activity and receives its result |
src/com.example.android.apis/app/SendResult.java |
Allows user to pick an option and sends it back to its caller |
/res/any/layout/receive_result.xml |
Defines contents of the ReceiveResult screen |
/res/any/layout/send_result.xml |
Defines contents of the SendResult screen |
|