NotificationCompat.CallStyle
public class NotificationCompat.CallStyle extends NotificationCompat.Style
| java.lang.Object | ||
| ↳ | androidx.core.app.NotificationCompat.Style | |
| ↳ | androidx.core.app.NotificationCompat.CallStyle |
Helper class for generating large-format notifications that include a caller and required actions, and indicate an incoming call. If the platform does not provide large-format notifications, this method has no effect. The user will always see the normal notification view. This class is a "rebuilder": It attaches to a Builder object and modifies its behavior, like so:
Notification notification = new NotificationCompat.Builder(mContext)
.setSmallIcon(R.drawable.new_post)
.setStyle(
new Notification.CallStyle.forIncomingCall(caller, declineIntent, answerIntent))
.build();setColorized.
Summary
Constants |
|
|---|---|
static final int |
Call type for incoming calls. |
static final int |
Call type for ongoing calls. |
static final int |
Call type for calls that are being screened. |
static final int |
Unknown call type. |
Public constructors |
|---|
CallStyle(@Nullable NotificationCompat.Builder builder)Creates a CallStyle linked to a notification builder. |
Public methods |
|
|---|---|
static @NonNull NotificationCompat.CallStyle |
forIncomingCall(Creates a CallStyle for an incoming call. |
static @NonNull NotificationCompat.CallStyle |
forOngoingCall(@NonNull Person person, @NonNull PendingIntent hangUpIntent)Creates a CallStyle for an ongoing call. |
static @NonNull NotificationCompat.CallStyle |
forScreeningCall(Creates a CallStyle for a call that is being screened. |
@NonNull NotificationCompat.CallStyle |
setAnswerButtonColorHint(@ColorInt int color)Sets an optional color to be used as a hint for the Answer action button's color. |
@NonNull NotificationCompat.CallStyle |
setDeclineButtonColorHint(@ColorInt int color)Sets an optional color to be used as a hint for the Decline or Hang Up action button's color. |
@NonNull NotificationCompat.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. |
@NonNull NotificationCompat.CallStyle |
setVerificationIcon(@Nullable Bitmap verificationIcon)Sets an optional icon to be displayed with |
@NonNull NotificationCompat.CallStyle |
setVerificationIcon(@Nullable Icon verificationIcon)Sets an optional icon to be displayed with |
@NonNull NotificationCompat.CallStyle |
setVerificationText(@Nullable CharSequence verificationText)Sets optional text to be displayed with an |
Inherited methods |
||||
|---|---|---|---|---|
|
Constants
CALL_TYPE_INCOMING
public static final int CALL_TYPE_INCOMING = 1
Call type for incoming calls. See EXTRA_CALL_TYPE.
CALL_TYPE_ONGOING
public static final int CALL_TYPE_ONGOING = 2
Call type for ongoing calls. See EXTRA_CALL_TYPE.
CALL_TYPE_SCREENING
public static final int CALL_TYPE_SCREENING = 3
Call type for calls that are being screened. See EXTRA_CALL_TYPE.
CALL_TYPE_UNKNOWN
public static final int CALL_TYPE_UNKNOWN = 0
Unknown call type. See EXTRA_CALL_TYPE.
Public constructors
CallStyle
public CallStyle(@Nullable NotificationCompat.Builder builder)
Creates a CallStyle linked to a notification builder.
| Parameters | |
|---|---|
@Nullable NotificationCompat.Builder builder |
the notification builder to link |
Public methods
forIncomingCall
public static @NonNull NotificationCompat.CallStyle forIncomingCall(
@NonNull Person person,
@NonNull PendingIntent declineIntent,
@NonNull PendingIntent answerIntent
)
Creates 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 | |
|---|---|
@NonNull Person person |
the person displayed as the caller the person also needs to have a non-empty name associated with it |
@NonNull PendingIntent declineIntent |
the intent to be sent when the user taps the decline action |
@NonNull PendingIntent answerIntent |
the intent to be sent when the user taps the answer action |
forOngoingCall
public static @NonNull NotificationCompat.CallStyle forOngoingCall(@NonNull Person person, @NonNull PendingIntent hangUpIntent)
Creates 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 | |
|---|---|
@NonNull 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 |
@NonNull PendingIntent hangUpIntent |
the intent to be sent when the user taps the hang up action |
forScreeningCall
public static @NonNull NotificationCompat.CallStyle forScreeningCall(
@NonNull Person person,
@NonNull PendingIntent hangUpIntent,
@NonNull PendingIntent answerIntent
)
Creates 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 | |
|---|---|
@NonNull Person person |
the person displayed as the caller the person also needs to have a non-empty name associated with it |
@NonNull PendingIntent hangUpIntent |
the intent to be sent when the user taps the hang up action |
@NonNull PendingIntent answerIntent |
the intent to be sent when the user taps the answer action |
setAnswerButtonColorHint
public @NonNull NotificationCompat.CallStyle setAnswerButtonColorHint(@ColorInt int color)
Sets an 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.
setDeclineButtonColorHint
public @NonNull NotificationCompat.CallStyle setDeclineButtonColorHint(@ColorInt int color)
Sets an 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.
setIsVideo
public @NonNull NotificationCompat.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.
setVerificationIcon
public @NonNull NotificationCompat.CallStyle setVerificationIcon(@Nullable Bitmap verificationIcon)
Sets an optional icon to be displayed with text as a verification status of the caller.
setVerificationIcon
public @NonNull NotificationCompat.CallStyle setVerificationIcon(@Nullable Icon verificationIcon)
Sets an optional icon to be displayed with text as a verification status of the caller.
setVerificationText
public @NonNull NotificationCompat.CallStyle setVerificationText(@Nullable CharSequence verificationText)
Sets optional text to be displayed with an icon as a verification status of the caller.