Prevent crash if person name wasn't found when creating a call notification on Android 31+
This commit is contained in:
parent
f24f3f2c85
commit
b4fd0ec5f4
1 changed files with 18 additions and 16 deletions
|
@ -164,22 +164,24 @@ class Api31Compatibility {
|
|||
|
||||
val builder = Notification.Builder(
|
||||
context, channel
|
||||
)
|
||||
.setStyle(
|
||||
Notification.CallStyle.forOngoingCall(caller, declineIntent).setIsVideo(isVideo)
|
||||
)
|
||||
.setSmallIcon(iconResourceId)
|
||||
.setAutoCancel(false)
|
||||
.setCategory(Notification.CATEGORY_CALL)
|
||||
.setVisibility(Notification.VISIBILITY_PUBLIC)
|
||||
.setWhen(System.currentTimeMillis())
|
||||
.setShowWhen(true)
|
||||
.setOngoing(true)
|
||||
.setColor(ContextCompat.getColor(context, R.color.notification_led_color))
|
||||
.setFullScreenIntent(
|
||||
pendingIntent,
|
||||
true
|
||||
) // This is required for CallStyle notification
|
||||
).apply {
|
||||
try {
|
||||
style = Notification.CallStyle.forOngoingCall(caller, declineIntent)
|
||||
.setIsVideo(isVideo)
|
||||
} catch (ise: IllegalStateException) {
|
||||
Log.e("[Api31 Compatibility] Can't use notification call style: $ise")
|
||||
}
|
||||
setSmallIcon(iconResourceId)
|
||||
setAutoCancel(false)
|
||||
setCategory(Notification.CATEGORY_CALL)
|
||||
setVisibility(Notification.VISIBILITY_PUBLIC)
|
||||
setWhen(System.currentTimeMillis())
|
||||
setShowWhen(true)
|
||||
setOngoing(true)
|
||||
setColor(ContextCompat.getColor(context, R.color.notification_led_color))
|
||||
// This is required for CallStyle notification
|
||||
setFullScreenIntent(pendingIntent, true)
|
||||
}
|
||||
|
||||
if (!corePreferences.preventInterfaceFromShowingUp) {
|
||||
builder.setContentIntent(pendingIntent)
|
||||
|
|
Loading…
Reference in a new issue