Android Notifications
ASecurityOn Android 8.0 (API 26) and later, every notification must be posted to an existing `NotificationChannel`. If the channel ID passed to `NotificationCompat.Builder` does not exist, the notification can be silently dropped. Create the channel before posting notifications, typically from `Application.onCreate()` or before the first notification: ```kotlin private const val NOTIFICATION_CHANNEL_ID = "default" fun createNotificationChannel(context: Context) { if (Build.VERSION.SDK_INT >= Build.VER...
- 584 stars
- 0 votes
- 0 copies
- 5 views
- Added September 5, 2026
Works with
Security analysis
100/100Pro scans all 18 files and shows the line behind each finding
npx -y skills add HoangNguyen0403/agent-skills-standard --skill android-notifications --agent claude-codeAre you the author of Android Notifications?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/hoangnguyen0403-android-notifications-agent-skills-standard)On Android 8.0 (API 26) and later, every notification must be posted to an existing `NotificationChannel`. If the channel ID passed to `NotificationCompat.Builder` does not exist, the notification can be silently dropped.
Create the channel before posting notifications, typically from `Application.onCreate()` or before the first notification:
```kotlin
private const val NOTIFICATION_CHANNEL_ID = "default"
fun createNotificationChannel(context: Context) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
val channel = NotificationChannel(
NOTIFICATION_CHANNEL_ID,
"Notifications",
NotificationManager.IMPORTANCE_HIGH
).apply {
description = "Application notifications"
}
context.getSystemService(NotificationManager::class.java)
.createNotificationChannel(channel)
}
}
```
Use that exact ID when building the notification and provide a valid small icon:
```kotlin
createNotificationChannel(this)
val notification = NotificationCompat.Builder(this, NOTIFICATION_CHANNEL_ID)
.setSmallIcon(R.drawable.ic_notification)
.setContentTitle(title)
.setContentText(body)
.setAutoCancel(true)
.build()
NotificationManagerCompat.from(this).notify(notificationId, notification)
```
Also check these common causes:
- The channel may have been disabled or its importance reduced in system settings. `NotificationManagerCompat.from(context).areNotificationsEnabled()` can detect app-level blocking, but channel-level settings must also be checked by the user.
- On Android 13 (API 33) and later, the app also needs `POST_NOTIFICATIONS` runtime permission. Declare it in the manifest and request it only after explaining the benefit to the user; a service cannot show the permission prompt itself.
- If the notification comes from FCM, ensure the `FirebaseMessagingService` is declared with the `com.google.firebase.MESSAGING_EVENT` intent action. For notification taps, use a `PendingIntent` and process its extras in both `MainActivity.onCreate()` and `onNewIntent()`.
The channel must be created once with a stable ID. Changing its importance in code later will not override a user's existing channel setting, so test with a fresh install or reset the channel when validating importance changes.
Files in this skill
- eval-1.baseline.md
- eval-1.with-skill.md
- eval-2.baseline.md
- eval-2.with-skill.md
- eval-3.baseline.md
- eval-3.with-skill.md
- trigger-1.md
- trigger-10.md
- trigger-11.md
- trigger-2.md
- trigger-3.md
- trigger-4.md
- trigger-5.md
- trigger-6.md
- trigger-7.md
- trigger-8.md
- trigger-9.md
Attribution
Related skills
View all in development →Comments
Loading comments…
Newsletter
Get the weekly list of safe new skills, and the ones we pulled.