I'm currently developing an Android app that opens a map with the assistance of Google Maps API, and adding markers every second, at specific locations.
When the map opens, I want to return back to MainActivity (by pressing the back button) to stop adding the markers from there , but when I try to re-open the MapActivity it creates a new instance of the activity. I want to keep alive the MapActivity in the background while the markers are being added, and when I try to re-open it I want all the markers to be visible. Here is the code that I use to open the map for the first time. I use the last line to open it again (by pressing another button).
Intent intent2 = new Intent(MainActivity.this, MapsActivity.class);
intent2.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
startActivityIfNeeded(intent2, 0);
Any help with this will be appreciated.
question from:
https://stackoverflow.com/questions/66055239/adding-markers-in-google-maps-api-android-by-keeping-mapactivity-alive-in-backgr 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…