getmap is deprecated getMapAsync doesnt work
<p>My app call getmap() method and notice that is depracated and I've to use getMapAsync() instead, however I've read all posts everywhere on the internet and none helped me. Sometimes I got "null pointer return message". I'll hope someone help me to do that.....</p>

<p>My MapFragment.java:</p>

<pre><code>private void setUpMapIfNeeded() {
    if (map == null) {
        map = ((MapView) view.findViewById(R.id.map)).getMap();
        if (ActivityCompat.checkSelfPermission(activity, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED &amp;&amp; ActivityCompat.checkSelfPermission(activity, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
            return;
        }
        map.setMyLocationEnabled(false);
        map.getUiSettings().setMyLocationButtonEnabled(false);
        map.getUiSettings().setZoomControlsEnabled(false);

        btnMyLocation.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                // Location loc = map.getMyLocation();
                if (myLocation != null) {
                    LatLng latLang = new LatLng(myLocation.getLatitude(),
                            myLocation.getLongitude());
                    animateCameraToMarker(latLang, true);
                }
            }
        });

        map.setOnCameraChangeListener(new OnCameraChangeListener() {

            public void onCameraChange(CameraPosition camPos) {
                if (currentZoom == -1) {
                    currentZoom = camPos.zoom;
                } else if (camPos.zoom != currentZoom) {
                    currentZoom = camPos.zoom;
                    return;
                }

                if (!isMapTouched) {
                    curretLatLng = camPos.target;
                    if (!isAddDestination) {
                        // layoutMarker.setVisibility(LinearLayout.VISIBLE);
                        if (listType.size() &gt; 0) {
                            stopUpdateProvidersLoaction();
                            getAllProviders(curretLatLng);
                        }
                        getAddressFromLocation(camPos.target, etSource);
                    }
                }
                isMapTouched = false;
            }

        });
    }

}
</code></pre>

<p>The onCreateView:
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {</p>

<p>...
...
            setUpMapIfNeeded();
...
        return view;
    }</p>

<p>My fragment_map.xml</p>

<pre><code>&lt;FrameLayout
    android:id="@+id/mapFrameLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center_horizontal"
    android:orientation="vertical"
    android:visibility="visible" &gt;

    &lt;com.google.android.gms.maps.MapView
        android:id="@+id/map"
        android:layout_width="match_parent"
        android:layout_height="match_parent" /&gt;
</code></pre>