I have two activities- act1 and act2. I want to transfer a String from act1 to act2 when the user presses a button and after some computation I want to transfer a LatLng from act2 to act1, while keeping both activities open (or at least be able to restore every change in act2 from the app start).
Things I tried:
I saw here that if I add some flags to the intent I won't start new activities when using
startActivity(). It works well getting from act1 to act2 but after starting act1 from act2 it stops act2, so in the next act2 opening it will make a new act2 copy.I looked at the not-deprecated version of
startActivityForResult, but since I need both of the activities open it's not what I want. I also want both of them to receive and return data.From here, using static data structure in one activity may not be good practice.
I tried using extras and
onNewIntentbut couldn't make it work (since I can't keep both activities running).
Background (if relevant):
I have an app with two activities- main, which stores a ListView, and a map activity.
The map must have a marker placed in each saved address.
The list has two button types:
- "Add a new place...", that open the map activity, and adds a new marker where the user wants.
- -some address-, that open the map in the location corresponding to this address.
I need a way to pass the desired address to the map so it'll show this location, and I also need to pass the new saved address back to the main activity after creating a location.