본문 바로가기
728x90
반응형

PendingIntent3

[Java] 안드로이드 서비스에서 Local Notification 보내기 build.gradle 종속성에 추가 dependencies { implementation 'com.android.support:support-compat:28.0.0' } Notification 채널 생성: Android 8.0 (API 레벨 26)부터 알림 채널을 사용해야 합니다. Application 클래스 또는 액티비티에서 아래의 코드를 사용하여 채널을 생성합니다. import android.app.NotificationChannel; import android.app.NotificationManager; import android.content.Context; import android.os.Build; public class NotificationUtils { public static fina.. 2023. 6. 26.
java.lang.IllegalArgumentException: com.xxx.xxx: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent. (targetSdkVersion 31 / Android 12) 안녕하세요. 오늘(2022년 11월 24일) 앱을 배포하려고 구글 플레이 스토어에 "새 버전 만들기"를 진행하려고 했더니 targetSdkVersion을 31로 (Android 12) 변경을 해야 등록이 가능하다고 메시지가 뜨네요. 그래서 30에서 31로 변경을 했습니다. 변경하고 테스트를 진행하니 아래 처럼 에러가 발생하면서 앱이 죽었습니다. java.lang.IllegalArgumentException: com.xxx.xxx: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent. 해당 에러는 서비스 내 Notificati.. 2022. 11. 24.
Android 10(TargetSDK 29) 이후 버전에서 파일 삭제 Android 10(TargetSDK 29) 이후 버전에서 Scoped Storage 적용으로, 어떤 파일을 삭제할때 사용자로부터 허락을 받아야 할 수도 있습니다. 예외로, 앱이 추가한 미디어 파일은 허락없이 삭제가 가능합니다. (TargetSDK 29 미만에서 앱이 미디어 파일을 삭제할때는 WRITE_EXTERNAL_STORAGE 권한을 갖고 있어야 합니다.) // TargetSDK 29 미만에서 앱 삭제 File file = new File("파일 절대(전체) 경로와 파일 이름"); if(file.delete()) { // 삭제 성공 } else { // 삭제 실패 } Android 10(TargetSDK 29) 이후 버전부터는 MediaStore를 이용하여 삭제를 합니다. 해당 방법을 소개한 곳은 .. 2022. 11. 14.
728x90
반응형