Notification.CallStyle

public static class Notification.CallStyle
extends Notification.Style

java.lang.Object
   ↳ android.app.Notification.Style
     ↳ android.app.Notification.CallStyle


Helper class for generating large-format notifications that include a large image attachment. Here's how you'd set the CallStyle on a notification:

 Notification notif = new Notification.Builder(mContext)
     .setSmallIcon(R.drawable.new_post)
     .setStyle(Notification.CallStyle.forIncomingCall(caller, declineIntent, answerIntent))
     .build();
 

Summary

Constants

int CALL_TYPE_INCOMING

Call type for incoming calls.

int CALL_TYPE_ONGOING

Call type for ongoing calls.

int CALL_TYPE_SCREENING

Call type for calls that are being screened.

int CALL_TYPE_UNKNOWN

Unknown call type.

Inherited fields

Public methods

static Notification.CallStyle forIncomingCall(Person person, PendingIntent declineIntent, PendingIntent answerIntent)

Create a CallStyle for an incoming call.

static Notification.CallStyle forOngoingCall(Person person, PendingIntent hangUpIntent)

Create a CallStyle for an ongoing call.

static Notification.CallStyle forScreeningCall(Person person, PendingIntent hangUpIntent, PendingIntent answerIntent)

Create a CallStyle for a call that is being screened.

Notification.CallStyle setAnswerButtonColorHint(int color)

Optional color to be used as a hint for the Answer action button's color.

Notification.CallStyle setDeclineButtonColorHint(int color)

Optional color to be used as a hint for the Decline or Hang Up action button's color.

Notification.CallStyle setIsVideo(boolean isVideo)

Sets whether the call is a video call, which may affect the icons or text used on the required action buttons.

Notification.CallStyle setVerificationIcon(Icon verificationIcon)

Optional icon to be displayed with text as a verification status of the caller.

Notification.CallStyle setVerificationText(CharSequence verificationText)

Optional text to be displayed with an icon as a verification status of the caller.

Inherited methods

Constants

CALL_TYPE_INCOMING

Added in API level 34
public static final int CALL_TYPE_INCOMING

Call type for incoming calls. See Notification.EXTRA_CALL_TYPE.

Constant Value: 1 (0x00000001)

CALL_TYPE_ONGOING

Added in API level 34
public static final int CALL_TYPE_ONGOING

Call type for ongoing calls. See Notification.EXTRA_CALL_TYPE.

Constant Value: 2 (0x00000002)

CALL_TYPE_SCREENING

Added in API level 34
public static final int CALL_TYPE_SCREENING

Call type for calls that are being screened. See Notification.EXTRA_CALL_TYPE.

Constant Value: 3 (0x00000003)

CALL_TYPE_UNKNOWN

Added in API level 34
public static final int CALL_TYPE_UNKNOWN

Unknown call type. See Notification.EXTRA_CALL_TYPE.

Constant Value: 0 (0x00000000)

Public methods

forIncomingCall

Added in API level 31
public static Notification.CallStyle forIncomingCall (Person person, 
                PendingIntent declineIntent, 
                PendingIntent answerIntent)

Create a CallStyle for an incoming call. This notification will have a decline and an answer action, will allow a single custom action, and will have a default content text for an incoming call.

Parameters
person Person: The person displayed as the caller. The person also needs to have a non-empty name associated with it. This value cannot be null.

declineIntent PendingIntent: The intent to be sent when the user taps the decline action This value cannot be null.

answerIntent PendingIntent: The intent to be sent when the user taps the answer action This value cannot be null.

Returns
Notification.CallStyle This value cannot be null.

forOngoingCall

Added in API level 31
public static Notification.CallStyle forOngoingCall (Person person, 
                PendingIntent hangUpIntent)

Create a CallStyle for an ongoing call. This notification will have a hang up action, will allow up to two custom actions, and will have a default content text for an ongoing call.

Parameters
person Person: The person displayed as being on the other end of the call. The person also needs to have a non-empty name associated with it. This value cannot be null.

hangUpIntent PendingIntent: The intent to be sent when the user taps the hang up action This value cannot be null.

Returns
Notification.CallStyle This value cannot be null.

forScreeningCall

Added in API level 31
public static Notification.CallStyle forScreeningCall (Person person, 
                PendingIntent hangUpIntent, 
                PendingIntent answerIntent)

Create a CallStyle for a call that is being screened. This notification will have a hang up and an answer action, will allow a single custom action, and will have a default content text for a call that is being screened.

Parameters
person Person: The person displayed as the caller. The person also needs to have a non-empty name associated with it. This value cannot be null.

hangUpIntent PendingIntent: The intent to be sent when the user taps the hang up action This value cannot be null.

answerIntent PendingIntent: The intent to be sent when the user taps the answer action This value cannot be null.

Returns
Notification.CallStyle This value cannot be null.

setAnswerButtonColorHint

Added in API level 31
public Notification.CallStyle setAnswerButtonColorHint (int color)

Optional color to be used as a hint for the Answer action button's color. The system may change this color to ensure sufficient contrast with the background. The system may choose to disregard this hint if the notification is not colorized.

Parameters
color int

Returns
Notification.CallStyle This value cannot be null.

setDeclineButtonColorHint

Added in API level 31
public Notification.CallStyle setDeclineButtonColorHint (int color)

Optional color to be used as a hint for the Decline or Hang Up action button's color. The system may change this color to ensure sufficient contrast with the background. The system may choose to disregard this hint if the notification is not colorized.

Parameters
color int

Returns
Notification.CallStyle This value cannot be null.

setIsVideo

Added in API level 31
public Notification.CallStyle setIsVideo (boolean isVideo)

Sets whether the call is a video call, which may affect the icons or text used on the required action buttons.

Parameters
isVideo boolean

Returns
Notification.CallStyle This value cannot be null.

setVerificationIcon

Added in API level 31
public Notification.CallStyle setVerificationIcon (Icon verificationIcon)

Optional icon to be displayed with text as a verification status of the caller.

Parameters
verificationIcon Icon: This value may be null.

Returns
Notification.CallStyle This value cannot be null.

setVerificationText

Added in API level 31
public Notification.CallStyle setVerificationText (CharSequence verificationText)

Optional text to be displayed with an icon as a verification status of the caller.

Parameters
verificationText CharSequence: This value may be null.

Returns
Notification.CallStyle This value cannot be null.