Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
244 views
in Technique[技术] by (71.8m points)

java - Adding Markers in google maps API android by keeping MapActivity alive in background

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...