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 8191875
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T04:01:24+00:00 2026-06-07T04:01:24+00:00

My problems is that onCreateView is not called in my MapFragment to reinstantiate/create the

  • 0

My problems is that onCreateView is not called in my MapFragment to reinstantiate/create the Fragment view (a MapView container) that is removed under onPause and onStop, and thus is null. Therefore the Fragment content displays black since map view is null.

This happens only under one condition, and that is when I power the screen off and on again. onCreateView acts normal when I swipe back to the mapview Fragment after it having been paused. The screen needs to go off often since I’m working on a location-based game.

Any help here would be greatly appreciated! =)

I have a FragmentActivity that has three tabs, ViewPager, FragmentPagerAdapter, and all that:

mapFragment = Fragment.instantiate(this, MapFragment.class.getName());
fragments.add(mapFragment);
fragments.add(Fragment.instantiate(this, NavHelperActivity.class.getName()));
fragments.add(Fragment.instantiate(this, CompassTabActivity.class.getName()));
mPagerAdapter  = new MyPagerAdapter(super.getSupportFragmentManager(), fragments);

pager = (ViewPager)super.findViewById(R.id.viewpager);
pager.setAdapter(this.mPagerAdapter);

MapFragment onCreateView(..) does this:

public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// This is where you specify you activity class
Intent i = new Intent(getActivity(), MapTabActivity.class);
Window w = mLocalActivityManager.startActivity("tag", i);
mapViewContainer = w.getDecorView();
mapViewContainer.setVisibility(View.VISIBLE);
mapViewContainer.setFocusableInTouchMode(true);
((ViewGroup)
mapViewContainer).setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS);
return mapViewContainer; }

And the onPause has to remove the map view:

if (mapViewContainer != null) {
mapViewContainer.setVisibility(View.GONE);
((ViewGroup) mapViewContainer.getParent()).removeView(mapViewContainer);
mapViewContainer = null;
}
  • 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-06-07T04:01:26+00:00Added an answer on June 7, 2026 at 4:01 am

    EDIT, UPDATE, SOLUTION:

    First, don’t null mapViewContainer explicitly.

    Set class variable:

    private static ViewGroup parent;
    

    Override onStart with this code:

    @Override
    public void onStart() {
         super.onStart();
         parent = mapViewContainer.getParent();
    }
    

    In onResume, do:

    @Override
    public void onResume() {
        super.onResume();
    
        if (mapViewContainer != null) {
            ((ViewGroup) parent).removeView(mapViewContainer);
            ((ViewGroup) parent).addView(mapViewContainer);
        }
    }
    

    Rest of the code should remain the same.

    Thanks to casaflowa for this.

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

Sidebar

Related Questions

http://removed.com/jquery/test.html# I have three problems that I need help with. 1 ) When you
I have two problems that I'm not sure are related: I have two DropDownList
Hi all I am having some problems that I think can be attributed to
I am new to asp.net mvc and i have problems that i think i
I have some localization problems in my webpage. There are basically two problems (that
I am attempting to compile some code, but am running into some problems that
I have to load huge (3000x3000) pictures in SWFLoader, and no problems with that
Does anyone know any site or book that presents problems like python challenge ,
Fortunately, I know the script works. The problems comes about that $('input[value=Log Out]').click(); Logout
I realized that I can have problems with single quotes in php arrays: <?php

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.