getMap() in onCreate(), created from layout gives nullpointerexception
This my code: import android.support.v4.app.Fragment; import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentManager; import com.google.android.gms.maps.GoogleMap; import com.google.android.gms.maps.SupportMapFragment; Inside onCreate() method:(I have only this at onCreate(), aside a bundle creation and variables asignation, using that bundle.) FragmentManager myFM = getSupportFragmentManager(); SupportMapFragment myMAPF =(SupportMapFragment)myFM. findFragmentById(R.id.mapfragment); map=myMAPF.getMap();//Exception at this line Layout: <fragment android:id="@+id