0
0
Android Kotlinmobile~20 mins

Notification channels in Android Kotlin - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Notification Channel Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
ui_behavior
intermediate
2:00remaining
Notification Channel Importance Level Effect
Which notification channel importance level will make the notification appear silently without sound or visual interruption?
ANotificationManager.IMPORTANCE_MIN
BNotificationManager.IMPORTANCE_LOW
CNotificationManager.IMPORTANCE_HIGH
DNotificationManager.IMPORTANCE_DEFAULT
Attempts:
2 left
💡 Hint
Think about the importance level that minimizes user interruption.
📝 Syntax
intermediate
2: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
AnotificationManager.registerNotificationChannel(channel)
BnotificationManager.createNotificationChannel(channel)
CnotificationManager.addNotificationChannel(channel)
DnotificationManager.createChannel(channel)
Attempts:
2 left
💡 Hint
Look for the official method name to add a channel to NotificationManager.
lifecycle
advanced
2: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?
AOnly when the user opens the notification settings
BEvery time you send a notification
COnce during app startup, before sending any notifications
DAfter sending the first notification
Attempts:
2 left
💡 Hint
Think about when channels must exist for notifications to work properly.
🧠 Conceptual
advanced
2: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?
AThe importance level remains as the user last set it and does not change automatically
BThe importance level updates immediately to the new value
CThe channel is deleted and recreated with the new importance
DThe app crashes when sending notifications on that channel
Attempts:
2 left
💡 Hint
Consider user control over notification settings after channel creation.
🔧 Debug
expert
3: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)
AThe small icon resource is missing, causing a crash
BThe notification ID must be zero for Android 8+
CThe Notification.Builder constructor should not include channelId on Android 8+
DThe notification channel was not registered with notificationManager.createNotificationChannel(channel)
Attempts:
2 left
💡 Hint
Check if the channel is properly registered before sending notifications.