본문 바로가기

IT개발일지/Android

[Android] Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent

안드로이드 SDK를 31로 잡고 작업을 할경우

Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent

위와 같은 에러메세지가 나온다.

-> 변경전

pIntent = PendingIntent.getActivity(this, 1 /* Request code */, targetIntent,
        PendingIntent.FLAG_UPDATE_CURRENT );

-> 변경후

pIntent = PendingIntent.getActivity(this, 1 /* Request code */, targetIntent,
        PendingIntent.FLAG_IMMUTABLE  );

 

이 경우 안내해주는 에러메시지라서 수정하기가 완전 간편했다.