First launch of Activity with Google Maps is very slow

前端 未结 9 1749
礼貌的吻别
礼貌的吻别 2020-12-02 12:37

I want to have SupportMapFragment in one of my Activity. I add this fragment directly to layout xml and this layout set as content view. But when Activity is launched for th

9条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-02 12:50

    I had the same issue and the MapsInitializer trick didn't work for me.

    The best solution to the problem, in my humble opinion, is to load by hand the Map Fragment as described from other users. It's not an hacky solution, you just have to deal yourself with the fragment instance

    mMapFragment = MapFragment.newInstance();
    fragmentManager.beginTransaction().replace(R.id.map_fragment_container, fragment, FRAGMENT_GOOGLEMAPS_TAG).commit();
    

提交回复
热议问题