Fortschrittsmeldung zeigt keine Segmentierungsfarben oder Fortschritts -Symbol für ältere Android -VersionenAndroid

Forum für diejenigen, die für Android programmieren
Anonymous
 Fortschrittsmeldung zeigt keine Segmentierungsfarben oder Fortschritts -Symbol für ältere Android -Versionen

Post by Anonymous »

Ich habe eine Fortschrittsbenachrichtigung mit dem Android SDK (Targeting Version 36) implementiert. Die Benachrichtigung funktioniert und die Fortschrittsaktualisierungen für Android 16 korrekt, aber auf älteren Android -Versionen sind die Segmentierungsfarben und das Fortschrittssymbol nicht sichtbar. < /P>

Code: Select all

private fun buildNotification(
orderId: String?,
state: OrderNotificationState
): NotificationCompat.Builder {
val title = state.title
val content = state.content
val progress = state.progress.coerceIn(0, MAX_PROGRESS)
createNotificationChannel(appContext)
return NotificationCompat.Builder(appContext, CHANNEL_ID)
.setSmallIcon(R.drawable.ic_logo_notification)
.setContentTitle(title)
.setContentText(content)
.setLargeIcon(
IconCompat.createWithResource(appContext, largeLogoResId).toIcon(appContext)
)
// .setContentIntent(pendingIntent)
.setOngoing(true)
.setRequestPromotedOngoing(true)
.setOnlyAlertOnce(true)
.setStyle(buildProgressStyle(progress))
.setCategory(NotificationCompat.CATEGORY_PROGRESS)
}
< /code>
Und hier ist meine Implementierung des Fortschrittsstils < /p>
private fun buildProgressStyle(currentProgress: Int): NotificationCompat.ProgressStyle {
val progressStyle = NotificationCompat.ProgressStyle()
progressStyle.setProgressTrackerIcon(
IconCompat.createWithResource(appContext, progressTrackerIconResId)
)
progressStyle.setProgressSegments(
listOf(
NotificationCompat.ProgressStyle.Segment(currentProgress)
.setColor(PROGRESSED_COLOR_INT),
NotificationCompat.ProgressStyle.Segment((MAX_PROGRESS - currentProgress))
.setColor(PENDING_COLOR_INT)
)
)
progressStyle.setProgress(currentProgress)
return progressStyle
}
Warum zeigt der Android 14 den Stil nicht?

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post