The Special Permissions plugin handles Android permissions that cannot be requested through normal runtime dialogs. These require the user to manually enable them in system settings.
Setup
The special permissions plugin is already registered in the default AppTemplate.
API
special.Request(perm SpecialType) (string, error)
Opens the system settings screen for the given permission type.
special.Check(perm SpecialType) (bool, error)
Checks whether the given special permission is currently granted.
Special Permission Types
| Type | Settings Screen | Android Version |
|---|---|---|
Accessibility |
Settings.ACTION_ACCESSIBILITY_SETTINGS |
All |
AllFilesAccess |
Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION |
11+ |
BatteryExemption |
Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZERS |
6.0+ |
NotificationAccess |
Settings.ACTION_NOTIFICATION_LISTENER_SETTINGS |
All |
Convenience Helpers
| Function | Description |
|---|---|
RequestAccessibility() (string, error) |
Opens Accessibility settings |
RequestAllFilesAccess() (string, error) |
Opens All Files Access settings (Android 11+) |
RequestBatteryExemption() (string, error) |
Opens battery optimization exemption dialog |
RequestNotificationAccess() (string, error) |
Opens notification access settings |
RequestAppSettings() (string, error) |
Opens app-specific system settings |
CheckAccessibility() (bool, error) |
Checks if Accessibility is granted |
CheckAllFilesAccess() (bool, error) |
Checks if All Files Access is granted |
CheckBatteryExemption() (bool, error) |
Checks if battery exemption is granted |
CheckNotificationAccess() (bool, error) |
Checks if notification access is granted |
Example
import "github.com/sweet-juice/sweetjuice/plugins/special"
// Request battery exemption
special.RequestBatteryExemption()
// Request notification access
special.RequestNotificationAccess()
// Check if notification access is granted
granted, _ := special.CheckNotificationAccess()
Android Notes
- These permissions cannot be requested via
requestPermissions(). - The user must manually enable them in the system settings screen.
AllFilesAccessrequires Android 11 (API 30) or higher.NotificationAccessrequires aNotificationListenerServicedeclared in the app manifest with theBIND_NOTIFICATION_LISTENER_SERVICEpermission.