Skip to content

feat: add POST_NOTIFICATIONS permission and runtime request#195

Merged
ErikBjare merged 2 commits into
ActivityWatch:masterfrom
TimeToBuildBob:feat/post-notifications-permission
Jul 24, 2026
Merged

feat: add POST_NOTIFICATIONS permission and runtime request#195
ErikBjare merged 2 commits into
ActivityWatch:masterfrom
TimeToBuildBob:feat/post-notifications-permission

Conversation

@TimeToBuildBob

Copy link
Copy Markdown
Contributor

Closes part of #189.

What

  • Adds POST_NOTIFICATIONS to AndroidManifest.xml
  • Adds a runtime permission request in MainActivity using ActivityResultContracts.RequestPermission()

Why

On Android 13+ (API 33), the OS requires both a manifest declaration and a runtime grant for POST_NOTIFICATIONS before it will surface any notification — including the foreground service notification from BackgroundService. Without this, the notification channel exists but the notification is silently suppressed, which is why users (and the emulator recording) see no notification in the drawer.

The runtime request fires once at launch (after onboarding), is guarded by Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU, and is skipped if the permission is already granted. It's a no-op on Android < 13.

Effect

Once granted, the "ActivityWatch Server / Server running in background" foreground notification will appear in the notification drawer while the app is backgrounded — which also makes it demonstrable for the Play Console FOREGROUND_SERVICE_SPECIAL_USE video requirement.

Adds the POST_NOTIFICATIONS manifest permission required on Android 13+
(API 33) for the foreground service notification to surface in the
notification drawer. Without this declaration and the accompanying
runtime grant, the OS silently suppresses the notification channel.

MainActivity now requests the permission at launch (after onboarding)
using the ActivityResultContracts API. The request is a no-op on
Android < 13 and on devices where the permission is already granted.
@greptile-apps

greptile-apps Bot commented Jul 23, 2026

Copy link
Copy Markdown

Greptile Summary

Adds Android 13 notification permission handling.

  • Declares POST_NOTIFICATIONS in the application manifest.
  • Requests the permission once after onboarding when it has not already been granted.
  • Persists whether the permission prompt has been launched to avoid repeated requests.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains in the fix for repeated notification permission requests.

Important Files Changed

Filename Overview
mobile/src/main/AndroidManifest.xml Declares the POST_NOTIFICATIONS permission required on Android 13 and later.
mobile/src/main/java/net/activitywatch/android/AWPreferences.kt Persists whether the notification permission request has already been launched.
mobile/src/main/java/net/activitywatch/android/MainActivity.kt Requests notification permission once after onboarding when running on Android 13 or later and permission remains ungranted.

Reviews (2): Last reviewed commit: "fix: avoid repeated notification permiss..." | Re-trigger Greptile

Comment thread mobile/src/main/java/net/activitywatch/android/MainActivity.kt
@TimeToBuildBob

Copy link
Copy Markdown
Contributor Author

@greptileai review

@TimeToBuildBob

Copy link
Copy Markdown
Contributor Author

CI-green and mergeable (Greptile 5/5) — waiting only on a maintainer click.

This PR is ready to merge, but the bot has pull-only access to this repo and can't self-merge — surfacing it here so it isn't lost. The monitoring loop will stop re-flagging it now that this note is posted.

@ErikBjare
ErikBjare merged commit 3144444 into ActivityWatch:master Jul 24, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants