Android 12.0 (API 수준 31) 이상에서 시스템은 CallStyle 알림 템플릿을 제공하여 전화 알림을 다른 유형의 알림과 구분합니다. 이 템플릿을 사용하여 수신 전화 또는 진행 중인 전화 알림을 만듭니다. 이 템플릿은 발신자 정보와 필수 작업(예: 전화 수신 또는 거부)이 포함된 대형 알림을 지원합니다.
수신 및 진행 중인 통화는 우선순위가 높은 이벤트이므로 이러한 알림은 알림 창에서 최우선순위를 받습니다. 또한 이 순위를 통해 시스템은 우선순위가 지정된 통화를 다른 기기로 전달할 수 있습니다.
CallStyle 알림 템플릿에는 다음과 같은 필수 작업이 포함됩니다.
- 수신 전화에 대해 받기 또는 거부
- 진행 중인 통화 끊기
- 통화 선택을 위해 받기 또는 끊기를 선택합니다.
이 스타일의 작업은 버튼으로 표시되며 시스템에서 적절한 아이콘과 텍스트를 자동으로 추가합니다. 버튼의 수동 라벨 지정은 지원되지 않습니다. 알림 디자인 원칙에 관한 자세한 내용은 알림을 참고하세요.

필수 작업은 다음 섹션의 hangupIntent 및 answerIntent과 같은 인텐트로 전달됩니다. 각각은 시스템에서 유지관리하는 토큰의 참조입니다. 토큰은 여러 앱과 프로세스 간에 전달할 수 있는 가벼운 객체입니다. 시스템은 토큰의 전체 기간을 관리하고, PendingIntent를 만든 앱이 더 이상 실행되지 않더라도 PendingIntent를 사용할 수 있도록 합니다. 다른 앱에 PendingIntent를 부여하면 거부 또는 응답과 같이 지정된 작업을 실행할 권한을 부여하는 것입니다.
이 권한은 인텐트를 만든 앱이 실행 중이 아니더라도 부여됩니다. 자세한 내용은 PendingIntent 참고 문서를 확인하세요.
Android 14 (API 수준 34)부터는 전화 알림을 닫을 수 없도록 구성할 수 있습니다. 이렇게 하려면 Notification.Builder#setOngoing(true)를 통해 Notification.FLAG_ONGOING_EVENT와 함께 CallStyle 알림을 사용합니다.
다음은 CallStyle 알림과 함께 다양한 메서드를 사용하는 예시입니다.
// Create a new call, setting incoming caller. val incomingCaller = Person.Builder() .setName("Jane Doe") .setImportant(true) .build()
수신 전화
forIncomingCall() 메서드를 사용하여 수신 전화에 대한 통화 스타일 알림을 만듭니다.
// For demonstrative purposes only, should use a well-defined Intents. val contentIntent = PendingIntent.getActivity(context, 0, Intent(), PendingIntent.FLAG_IMMUTABLE) val declineIntent = PendingIntent.getActivity(context, 0, Intent(), PendingIntent.FLAG_IMMUTABLE) val hangupIntent = PendingIntent.getActivity(context, 0, Intent(), PendingIntent.FLAG_IMMUTABLE) val answerIntent = PendingIntent.getActivity(context, 0, Intent(), PendingIntent.FLAG_IMMUTABLE) // Create a call style notification for an incoming call. val builderForIncomingCall = NotificationCompat.Builder(context, CHANNEL_ID) .setContentIntent(contentIntent) .setSmallIcon(R.drawable.ic_logo) .setStyle( NotificationCompat.CallStyle.forIncomingCall(incomingCaller, declineIntent, answerIntent)) .addPerson(incomingCaller)
진행 중인 통화
forOngoingCall() 메서드를 사용하여 진행 중인 통화에 대한 통화 스타일 알림을 만듭니다.
// Create a call style notification for an ongoing call. val builderForOngoingCall = NotificationCompat.Builder(context, CHANNEL_ID) .setContentIntent(contentIntent) .setSmallIcon(R.drawable.ic_logo) .setStyle( NotificationCompat.CallStyle.forOngoingCall(callerAtOtherEnd, hangupIntent)) .addPerson(caller)
통화 선택하기
forScreeningCall() 메서드를 사용하여 통화 선별을 위한 통화 스타일 알림을 만듭니다.
// Create a call style notification for screening a call. val builder = NotificationCompat.Builder(context, CHANNEL_ID) .setContentIntent(contentIntent) .setSmallIcon(R.drawable.ic_logo) .setStyle( NotificationCompat.CallStyle.forScreeningCall(caller, hangupIntent, answerIntent)) .addPerson(caller)
더 많은 Android 버전에서 호환성 제공
API 수준 31 이상에서 부여되는 높은 순위를 할당하기 위해 API 버전 30 이하의 CallStyle 알림을 포그라운드 서비스와 연결합니다. 또한 API 버전 30 이하의 CallStyle 알림은 setColorized() 메서드를 사용하여 알림을 색상화된 것으로 표시함으로써 유사한 순위를 달성할 수 있습니다.
CallStyle 알림과 함께 Telecom API를 사용합니다. 자세한 내용은 통신 프레임워크 개요를 참고하세요.