프로그래밍/ 안드로이드어플만들기
안드로이드 오류 - Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLEbe specified when creating a PendingIntent.
kugancity
2023. 1. 23. 22:18
반응형
안드로이드 어플에 커스텀탭 테스트하려는데 아래와 같은 에러 발생
오류 메세지가 자세하게 나와있어서 그냥 따라가면 간다.
안드로이드 버전 31부터 pendingintent에서 FLAG_IMMUTABLE 또는 FLAG_MUTABLE만 가능한데
가능하면 FLAG_IMMUTABLE을 쓰라고 한다.
java.lang.RuntimeException: Unable to start activity ComponentInfo:
java.lang.IllegalArgumentException: com.butlerdiary.butlerdiary:
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를 FLAG_IMMUTABLE로 수정하니 정상적으로 빌드가 된다.
//커스텀탭
public void openCustomTabs() {
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("*/*");
// 이전 버전
//PendingIntent pendingIntent = PendingIntent.getActivity(getApplicationContext(), 1, intent, 0);
// 수정 버전
PendingIntent pendingIntent = PendingIntent.getActivity(getApplicationContext(), 1, intent, PendingIntent.FLAG_IMMUTABLE);
참고: https://ddolcat.tistory.com/2393
728x90
반응형