Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4025906
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:54:17+00:00 2026-05-20T10:54:17+00:00

It is well know to people using Google Maps in an Android app that

  • 0

It is well know to people using Google Maps in an Android app that they can only use one MapActivity per process. There is a bug discussing this in detail along with the workaround of putting each MapActivity in a separate process. I don’t want to do this in my app for a few reason and have developed another workaround that seems to work.

For each Activity that contains a map, I have it extend ActivityGroup and create/destroy the MapActivity in onResume/onPause as a child activity. This ensures there will only be one instance of a MapActivity at a time (assuming you have one Activity showing at a time). Below is a simplified version of my implementation:

public class MyMapActivityGroup extends ActivityGroup {

    @Override
    protected void onResume() {
        super.onResume();

        addMapView();
    }

    @Override
    protected void onPause() {
        super.onPause();

        removeMapView();
    }

    private void addMapView() {
        Intent intent = new Intent(this, MyMapActivity.class);
        Window window = getLocalActivityManager().startActivity("map", intent);
        setContentView(window.getDecorView());
    }

    private void removeMapView() {
        setContentView(new FrameLayout(this));
        getLocalActivityManager().removeAllActivities();
    }

}

The MapActivity I am using is nothing special and doesn’t require any modification. It just sets a MapView as its content view.

This seems to work fine for me. But is there any downside to doing this? My main concern is a memory leak created when going between activities containing a map.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T10:54:18+00:00Added an answer on May 20, 2026 at 10:54 am

    I would guess that the only reason to not do this would be performance. The map activity can already be a bit of a dog, especially when starting it, so if you find yourself allocating and deallocating the view frequently, this might perform pretty poorly. However, its really dependent on how often the view will be created and removed, which depends entirely on behavioral aspects of your application.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Well I know it's not evil just not as pretty in semantics as <strong>
I know Java well. Which caveats and resources will help me cross to the
Maybe I just don't know .NET well enough yet, but I have yet to
I know, I would have thought the answer was obviously no as well, but
A Java version of this question was just answered, and, well, I don't know
I know that in the next version of ASP.NET we'll finally be able to
Well behaved windows programs need to allow users to save their work when they
We can see the growth of systems using peer to peer principles. But there
Well the subject is the question basically. Are there any version control systems out
Well, i've got a nice WPF book its called Sams Windows Presentation Foundation Unleashed.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.