Note that there are some explanatory texts on larger screens.

plurals
  1. POandroid maps stop responding after resuming fragment
    primarykey
    data
    text
    <p>Listed below is my basic code for controlling the maps. I do some really advanced stuff later. Everything seems to work perfect, until <code>onResume()</code>.</p> <p>Here is the layout, you navigate through the app in 1 single activity, with multiple fragments. This <code>mapFragment</code> is contained inside of a fragment. This works fine. However when I add another fragment and push this one on the back stack, when i come back to it later, the map is unresponsive.</p> <p>I tried fixing this by moving my call to <code>setupMaps();</code> into the <code>onResume()</code>, however this caused <code>gMaps</code> to be null when I get it from <code>gMaps = mapFragment.getMap();</code> in the <code>setViews()</code>.</p> <p>How should I handle this?</p> <pre><code> @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { root = inflater.inflate(R.layout.fragment_maps, container, false); setupMaps(); return root; } private void setupMaps() { gMaps = null; fm = getActivity().getSupportFragmentManager(); mapFragment = SupportMapFragment.newInstance(); android.support.v4.app.FragmentTransaction transaction = getChildFragmentManager().beginTransaction(); transaction.add(R.id.flMapContainer, mapFragment).commit(); } @Override public void onResume() { super.onResume(); mapFragment.onResume(); setViews(); } private void setViews() { gMaps = mapFragment.getMap(); getData(); // initializes overlays, markers, polygons etc. } @Override public void onPause() { mapFragment.onPause(); super.onPause(); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload