Note that there are some explanatory texts on larger screens.

plurals
  1. POandroid (Support)MapFragment getMap() return null
    primarykey
    data
    text
    <p>I allready read a lot topics about this problem but nothing helped. So I want to operate on a GoogleMap in a SupportMapFragment. In the FragmentActivity I initialized the map in the onCreate Method</p> <pre><code>@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.content_frame); // Initialize Google Maps Android API try { MapsInitializer.initialize(this); } catch (GooglePlayServicesNotAvailableException e) { e.printStackTrace(); } ... </code></pre> <p>the Code of my MapFragment looks exactly like this</p> <pre><code>public class MapFragment extends SupportMapFragment { private final String TAG = getClass().getSimpleName(); public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { return inflater.inflate(R.layout.map, null); } public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); } @Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); GoogleMap gMap = this.getMap(); Log.d(TAG, "getMap() " + ((gMap == null) ? "null" : gMap.toString())); // Setting Location and Zoom gMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng( 40.76793169992044f, -73.98180484771729f), 14.0f)); } } </code></pre> <p>Every time I am getting null with the getMap Method... any ideas?</p> <p>€dit:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;fragment xmlns:android="http://schemas.android.com/apk/res/android" xmlns:map="http://schemas.android.com/apk/res-auto" android:id="@+id/map" android:layout_width="match_parent" android:layout_height="match_parent" class="com.google.android.gms.maps.SupportMapFragment" map:cameraBearing="112.5" map:cameraTargetLat="-33.796923" map:cameraTargetLng="150.922433" map:cameraTilt="30" map:cameraZoom="50" map:mapType="normal" map:uiCompass="false" map:uiRotateGestures="true" map:uiScrollGestures="false" map:uiTiltGestures="true" map:uiZoomControls="false" map:uiZoomGestures="true" /&gt; </code></pre>
    singulars
    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