Search code examples
androidgoogle-maps-api-2

Google Map v2 Fragment Error


i write simple google map v2 android application but in my java file this line:

googleMap = ((SupportMapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();

have error! error:the getFragmentManager() is undefined for the type mainActivity. please help me my friends.


Solution

  • If you used SupportMapFragment then used getSupportFragmentManager()

    and if you used MapFragment then used getFragmentManager()

    Correct

    googleMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();