마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

안드로이드 스튜디오 구글맵 getSupportFragmentManager 에러 오류가 나요

0 추천
public class MapActivity extends Activity implements OnMapReadyCallback {

    private GoogleMap googleMap;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_map);

        SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.mapp);
        mapFragment.getMapAsync((OnMapReadyCallback) this);
 
오류가 뭔지 모르겠어요ㅠㅠ getSupportFragmentManager이 빨간 글씨로 바뀝니다ㅠ 그 위에 마우스 가져가면 Cannot resolve method 'getSupportFragmentManager' in 'MapActivity' 
이렇게 오류 메시지가 떠요 방법이 있을까요?
안드로린이 (150 포인트) 님이 2021년 12월 7일 질문

1개의 답변

0 추천
 
채택된 답변
SupportFragmentManager는 FragmentActivity에서 사용가능합니다.

https://developer.android.com/reference/android/support/v4/app/FragmentActivity.html

따라서 MapActivtiy가 FragmentActivity 의 하위 클래스여야 합니다.
spark (226,420 포인트) 님이 2021년 12월 7일 답변
안드로린이님이 2021년 12월 8일 채택됨
...