I would like some help in sending data backwards to an Activity
that is already running.
I want the user to be able to select an option from a list and then that selection be used in a previous activity. I know how to do it going forward using intents but can't see how that would work in this case without having an arbitrary number of the same activity windows running at the same time.
Sort of like changing the settings within the phone but more having access to a string. If you need any more information just ask.
There are two ways to do this, the first is rather than calling startActivity(), call startActivityForResult(), this is what the documentation has to say about it:
http://developer.android.com/reference/android/app/Activity.html
The other way to do it is to send out a broadcast at the end of your activity, and register a broadcastReceiver() in your original activity.
Take a look at Activity#startActivityForResult() and Activity#setResult() methods
You need to use startActivityForResult.
If you start the second activity using
startActivityForResult()
rather thanstartActivity
, then when the second activity completes you can set aresultCode
and anIntent
. It will then call the method:in your first
Activity
, where you can read theresultCode
and theIntent
data