본문 바로가기

MOBILE/android

[오류일기] android pendingIntent IllegalArgumentException

안드로이드 12를 타겟팅 하는 수준에서는

pending intent의 flag를 immutable or mutable 둘 중 하나를 꼭 명시해야 한다.

noti를 변경 가능한지 아닌지 명시해야함

noti의 Direct Reply Action을 사용한다면 flag를 mutable로 설정해야 한다.

 

예를 들면 이런식으로 flag를 두개를 동시에 설정할 수도 있다.

Intent intent=new Intent(this,subActivity.class);
PendingIntent pendingIntent=PendingIntent.getActivity(this,101,intent,
	PendingIntent.FLAG_UPDATE_CURRENT|PendingIntent.FLAG_IMMUTABLE);

 

구글 공식 문서에 pending intent로 noti를 보내는 설명이 자세하게 되어있으니 참고하면 좋음

https://developer.android.com/reference/android/app/PendingIntent