R
R
rmiron2017-11-22 09:53:59
Android
rmiron, 2017-11-22 09:53:59

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 :

the code
Intent mIntent = new Intent(Options.this, MapsActivity.class);
                mIntent.putExtra("countryName", countryNames[i]);
                startActivity(mIntent);


Intent code from the first Activity
the code
Bundle mBundle = getIntent().getExtras();
        if (mBundle != null) {
            String product = mBundle.getString("countryName");
            if (product == "Australia"){
                Australia.showInfoWindow();
            }
        }


tried in onResume() method.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mikhail Chvarkov, 2017-11-22
@rmiron

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 question

Ask a Question

731 491 924 answers to any question