NotificationCompat.CallStyle
class NotificationCompat.CallStyle : NotificationCompat.Style
| kotlin.Any | ||
| ↳ | 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 |
|
|---|---|
const Int |
Call type for incoming calls. |
const Int |
Call type for ongoing calls. |
const Int |
Call type for calls that are being screened. |
const Int |
Unknown call type. |
Public constructors |
|---|
CallStyle(builder: NotificationCompat.Builder?)Creates a CallStyle linked to a notification builder. |
Public functions |
|
|---|---|
java-static NotificationCompat.CallStyle |
forIncomingCall(Creates a CallStyle for an incoming call. |
java-static NotificationCompat.CallStyle |
forOngoingCall(person: Person, hangUpIntent: PendingIntent)Creates a CallStyle for an ongoing call. |
java-static NotificationCompat.CallStyle |
forScreeningCall(Creates a CallStyle for a call that is being screened. |
NotificationCompat.CallStyle |
setAnswerButtonColorHint(color: @ColorInt Int)Sets an optional color to be used as a hint for the Answer action button's color. |
NotificationCompat.CallStyle |
setDeclineButtonColorHint(color: @ColorInt Int)Sets an optional color to be used as a hint for the Decline or Hang Up action button's color. |
NotificationCompat.CallStyle |
setIsVideo(isVideo: Boolean)Sets whether the call is a video call, which may affect the icons or text used on the required action buttons. |
NotificationCompat.CallStyle |
setVerificationIcon(verificationIcon: Bitmap?)Sets an optional icon to be displayed with |
NotificationCompat.CallStyle |
@RequiresApi(value = 23)Sets an optional icon to be displayed with |
NotificationCompat.CallStyle |
setVerificationText(verificationText: CharSequence?)Sets optional text to be displayed with an |
Inherited functions |
||||
|---|---|---|---|---|
|
Constants
CALL_TYPE_INCOMING
const val CALL_TYPE_INCOMING = 1: Int
Call type for incoming calls. See EXTRA_CALL_TYPE.
CALL_TYPE_ONGOING
const val CALL_TYPE_ONGOING = 2: Int
Call type for ongoing calls. See EXTRA_CALL_TYPE.
CALL_TYPE_SCREENING
const val CALL_TYPE_SCREENING = 3: Int
Call type for calls that are being screened. See EXTRA_CALL_TYPE.
CALL_TYPE_UNKNOWN
const val CALL_TYPE_UNKNOWN = 0: Int
Unknown call type. See EXTRA_CALL_TYPE.
Public constructors
CallStyle
CallStyle(builder: NotificationCompat.Builder?)
Creates a CallStyle linked to a notification builder.
| Parameters | |
|---|---|
builder: NotificationCompat.Builder? |
the notification builder to link |
Public functions
forIncomingCall
java-static fun forIncomingCall(
person: Person,
declineIntent: PendingIntent,
answerIntent: PendingIntent
): NotificationCompat.CallStyle
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 | |
|---|---|
person: Person |
the person displayed as the caller the person also needs to have a non-empty name associated with it |
declineIntent: PendingIntent |
the intent to be sent when the user taps the decline action |
answerIntent: PendingIntent |
the intent to be sent when the user taps the answer action |
forOngoingCall
java-static fun forOngoingCall(person: Person, hangUpIntent: PendingIntent): NotificationCompat.CallStyle
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 | |
|---|---|
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 |
hangUpIntent: PendingIntent |
the intent to be sent when the user taps the hang up action |
forScreeningCall
java-static fun forScreeningCall(
person: Person,
hangUpIntent: PendingIntent,
answerIntent: PendingIntent
): NotificationCompat.CallStyle
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 | |
|---|---|
person: Person |
the person displayed as the caller the person also needs to have a non-empty name associated with it |
hangUpIntent: PendingIntent |
the intent to be sent when the user taps the hang up action |
answerIntent: PendingIntent |
the intent to be sent when the user taps the answer action |
setAnswerButtonColorHint
fun setAnswerButtonColorHint(color: @ColorInt Int): NotificationCompat.CallStyle
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
fun setDeclineButtonColorHint(color: @ColorInt Int): NotificationCompat.CallStyle
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
fun setIsVideo(isVideo: Boolean): NotificationCompat.CallStyle
Sets whether the call is a video call, which may affect the icons or text used on the required action buttons.
setVerificationIcon
fun setVerificationIcon(verificationIcon: Bitmap?): NotificationCompat.CallStyle
Sets an optional icon to be displayed with text as a verification status of the caller.
setVerificationIcon
@RequiresApi(value = 23)
fun setVerificationIcon(verificationIcon: Icon?): NotificationCompat.CallStyle
Sets an optional icon to be displayed with text as a verification status of the caller.
setVerificationText
fun setVerificationText(verificationText: CharSequence?): NotificationCompat.CallStyle
Sets optional text to be displayed with an icon as a verification status of the caller.