본문 바로가기
안드로이드

안드로이드12 위젯 PendingIntent Flag 오류

by Dokon Jang 2022. 11. 12.
반응형

안드로이드 프로젝트의 타겟을 31(안드로이드12)로 설정하고 위젯에서 아래와 같은 오류가 발생했습니다.

Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.

 

PendingIntent에 FLAG_IMMUTABLE 또는 FLAG_MUTABLE이 필요하다는 오류네요.

아래와 같이 PendingIntent.FLAG_MUTABLE를 추가하니 잘 작동합니다.

PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT  | PendingIntent.FLAG_MUTABLE);

PendingIntent homePendingIntent = PendingIntent.getActivity(context, 0, homeIntent, PendingIntent.FLAG_UPDATE_CURRENT  | PendingIntent.FLAG_MUTABLE);
반응형

댓글