Guard settings intents against missing activities - #113
Merged
Conversation
Wrap the all-files-access, per-app notification, and battery-optimization settings launches in a helper that tries each action in turn and swallows ActivityNotFoundException, falling back to the device-wide list and finally the always-present app details page. Prevents a first-run crash on OEM builds that lack a matching activity for these actions.
in-jun
commented
Jul 18, 2026
in-jun
left a comment
Owner
Author
There was a problem hiding this comment.
Confirmed this resolves #69 cleanly. All four startActivity sites in Permissions.kt — the only settings launches in the app — now route through startFirstAvailable, which tries each action in order, swallows ActivityNotFoundException, and lands on the always-present app-details page as a last resort. The preferred intent is still attempted first in every case, so happy-path behavior is unchanged and the only new behavior is the fallback chain.
A couple of things I checked:
- Fallback constants are safe at our
minSdk26:ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS(23) andACTION_APP_NOTIFICATION_SETTINGS(26) are always available, andACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION(30) stays inside the existingSDK_INT >= Rguard. - If every intent fails the call is a harmless no-op rather than a crash, which is the whole point of the change.
The device-wide list / app-details fallbacks drop the user a step short of the exact toggle, but that's a reasonable trade for never crashing the first-run flow, and it matches the approach outlined in the issue. Looks good to me.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The onboarding permission banner launches three system settings actions (all-files-access, per-app notifications, battery-optimization exemption). A matching activity for these isn't guaranteed on every device/OEM build, so on an affected phone tapping the banner threw
ActivityNotFoundExceptionand crashed the app during first-run.startFirstAvailablehelper that tries each action in order, swallowsActivityNotFoundException, and falls back to the device-wide list where one exists and finally the always-present app details page.Fixes #69