Android Notifications
ASecurityNo. On Android 13 (API 33) and later, request `POST_NOTIFICATIONS` at a contextually useful point after explaining why notifications help. Do not show the system prompt unconditionally on the first app launch; a short priming dialog improves the user's understanding and avoids an unexpected permission request. Declare the permission: ```xml <uses-permission android:name="android.permission.POST_NOTIFICATIONS" /> ``` Register a launcher in an activity and guard it by API level and current perm...
- 584 stars
- 0 votes
- 0 copies
- 10 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-fd8a38b9)No. On Android 13 (API 33) and later, request `POST_NOTIFICATIONS` at a contextually useful point after explaining why notifications help. Do not show the system prompt unconditionally on the first app launch; a short priming dialog improves the user's understanding and avoids an unexpected permission request.
Declare the permission:
```xml
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
```
Register a launcher in an activity and guard it by API level and current permission state:
```kotlin
private val notificationPermissionLauncher =
registerForActivityResult(ActivityResultContracts.RequestPermission()) { granted ->
if (granted) {
// Notifications can now be posted.
} else {
// Respect the decision; offer notification settings later if useful.
}
}
private fun requestNotificationPermissionIfNeeded() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU &&
checkSelfPermission(Manifest.permission.POST_NOTIFICATIONS) !=
PackageManager.PERMISSION_GRANTED
) {
notificationPermissionLauncher.launch(Manifest.permission.POST_NOTIFICATIONS)
}
}
```
Call that function only after a priming explanation, for example when the user enables alerts or reaches a feature that depends on them:
```kotlin
AlertDialog.Builder(this)
.setTitle("Enable notifications?")
.setMessage("Get timely updates about your orders.")
.setPositiveButton("Continue") { _, _ ->
requestNotificationPermissionIfNeeded()
}
.setNegativeButton("Not now", null)
.show()
```
Create the app's `NotificationChannel` separately on Android 8+ before posting notifications. The runtime permission and the channel are different gates: API 33+ requires both the permission and a valid channel, while older Android versions do not use `POST_NOTIFICATIONS`. If the user denies the request, do not repeatedly prompt; respect the choice and provide a settings route at an appropriate later point if the product needs one.
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.