일반 Intent로도 화면을 띄울 수 있지만 시스템의 제약과 사용자의 빠른 반응을 고려했을 때 FullScreenIntent가 적합한 이유는 잠금 화면에서도 즉시 전면 화면을 띄우고, 포그라운드 서비스와의 결합을 통해 알림을 관리할 수 있음
// NotificationManager 초기화
val notificationManager = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
// 채널 ID 설정 (필요 시)
val channelId = "my_channel_id"
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
val channel = NotificationChannel(channelId, "My Notifications", NotificationManager.IMPORTANCE_HIGH)
notificationManager.createNotificationChannel(channel)
}
// 풀스크린 인텐트 설정
val intent = Intent(this, FullScreenActivity::class.java)
val pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT)
// 풀스크린 알림 생성
val notification = NotificationCompat.Builder(this, channelId)
.setContentTitle("긴급 전화")
.setContentText("전화가 왔습니다. 바로 받으세요!")
.setSmallIcon(R.drawable.ic_notification)
.setFullScreenIntent(pendingIntent, true) // 풀스크린 인텐트를 설정
.setPriority(NotificationCompat.PRIORITY_HIGH)
.build()
// 알림을 표시
notificationManager.notify(1, notification)
IMPORTANCE_HIGH로 설정해야 작동⇒ 풀스크린 인텐트는 강력한 기능이지만, 남용하면 사용자 경험에 부정적인 영향을 미칠 수 있음. 꼭 필요한 경우에만 사용하고, 시스템 정책과 사용자 환경을 철저히 고려해야 함
관련해서 앱 리젝먹고 대응 중이었는데 도움이 되었습니다!