-1

So the working of my application is it has an activity called "Add Reminder" this activity has some textbox which the user can enter values in them then the user goes to the next activity by clicking a button which is a GoogleMaps and they can tap a location and get their Latitude and Longitude after tapping on the Marker the Intent stores the value of latitude and longitude. When users click a button which is a tick icon then these values are being sent to the previous activity so the issue which I'm facing is when the user goes backs to the "Add Reminder" Activity. if the user types anything before going to the new GoogleMaps activity and comes back the TextBox is empty as Android consider this as a new fresh activity is there a way to retain those values until the user comes from the GoogleMaps activity.

Add Reminder Actitivity Intent

startActivity(new Intent(AddReminderActivity.this,MapsActivity.class));

GoogleMaps Actitivity Intent

Intent data = new Intent(MapsActivity.this, AddReminderActivity.class);
                    Bundle b = new Bundle();
                    b.putString("lat", latitude.toString());
                    b.putString("lng", longitude.toString());
                    data.putExtra("personBdl", b);
                    startActivity(data);

1 Answers1

1

You're doing things wrong. You shouldn't be returning to the AddReminder by launching an Intent. You return by finish(), going back to the previous activity. To return a value from the AddReminder activity, use startActivityForResult to start the MapsActivity, and set a result bundle before calling finish.

Gabe Sechan
  • 90,003
  • 9
  • 87
  • 127