Challenge - 5 Problems
Notification Channel Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ ui_behavior
intermediate2:00remaining
Notification Channel Importance Level Effect
Which notification channel importance level will make the notification appear silently without sound or visual interruption?
Attempts:
2 left
💡 Hint
Think about the importance level that minimizes user interruption.
✗ Incorrect
IMPORTANCE_MIN shows notifications silently without sound or visual interruption, unlike HIGH or DEFAULT which alert the user.
📝 Syntax
intermediate2:00remaining
Correct Syntax to Create a Notification Channel
Which Kotlin code snippet correctly creates and registers a notification channel named "news" with high importance?
Android Kotlin
val channelId = "news" val channelName = "News Updates" val importance = NotificationManager.IMPORTANCE_HIGH val channel = NotificationChannel(channelId, channelName, importance) val notificationManager = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager // Missing code here to register channel
Attempts:
2 left
💡 Hint
Look for the official method name to add a channel to NotificationManager.
✗ Incorrect
The correct method to register a notification channel is createNotificationChannel(channel). Other methods do not exist.
❓ lifecycle
advanced2:00remaining
When to Create Notification Channels
At what point in an Android app's lifecycle should you create notification channels to ensure they are available before sending notifications?
Attempts:
2 left
💡 Hint
Think about when channels must exist for notifications to work properly.
✗ Incorrect
Notification channels must be created once before sending notifications, typically during app startup or initialization.
🧠 Conceptual
advanced2:00remaining
Effect of Changing Notification Channel Settings After Creation
If you change the importance level of an existing notification channel in your app code and reinstall the app, what happens to the channel's importance level on the device?
Attempts:
2 left
💡 Hint
Consider user control over notification settings after channel creation.
✗ Incorrect
Once a notification channel is created, the system ignores changes to its settings in code; user changes persist and override code changes.
🔧 Debug
expert3:00remaining
Why Notifications Fail to Appear on Android 8+
Given this Kotlin code snippet, why might notifications not appear on devices running Android 8.0 or higher?
val channelId = "alerts"
val channel = NotificationChannel(channelId, "Alerts", NotificationManager.IMPORTANCE_HIGH)
val notificationManager = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
// Missing code here
val notification = Notification.Builder(this, channelId)
.setContentTitle("Warning")
.setContentText("Check your settings")
.setSmallIcon(R.drawable.ic_alert)
.build()
notificationManager.notify(1, notification)
Attempts:
2 left
💡 Hint
Check if the channel is properly registered before sending notifications.
✗ Incorrect
On Android 8.0+, notifications require a registered channel. Without calling createNotificationChannel, notifications won't show.