Answer the question
In order to leave comments, you need to log in
Working with Intent in Android, Why does Activity restart?
Welcome all!
I ask you for help in solving the following question:
There is a small application on Android with Google Maps maps. Places are marked on the map. There is a second List Activity with the names of these places. So, having entered the second Activity, selecting one of the proposed items, the application should return to the first Activity, and an information window with a description of the location should appear on the map. BUT, the first Activity is simply restarted and hence the info window is not opened. Where did I go wrong?
Intent code for the second Activity :
Intent mIntent = new Intent(Options.this, MapsActivity.class);
mIntent.putExtra("countryName", countryNames[i]);
startActivity(mIntent);
Bundle mBundle = getIntent().getExtras();
if (mBundle != null) {
String product = mBundle.getString("countryName");
if (product == "Australia"){
Australia.showInfoWindow();
}
}
Answer the question
In order to leave comments, you need to log in
from the first Activity, open the second one using the startActivityForResult method. Then you can return the data by closing the second Activity and there will be no restart of the first one. ( lesson )
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question