Middle
What changed in the permission system after Android 6?
sobes.tech AI
Answer from AI
In Android 6.0 (API 23), the runtime permissions model was introduced.
Main changes:
- Dynamic permissions: Apps request permissions not at installation, but immediately before the first use of a feature requiring that permission.
- Permission grouping: Permissions are grouped by type. If a user grants permission to one member of a group (e.g.,
READ_CONTACTS), they automatically get permissions for other members of that group (e.g.,WRITE_CONTACTS). - Revoked permissions: Users can revoke any granted permission at any time through device settings.
In app code, this requires additional logic to check for permission availability and request it if not already granted.
Example of checking and requesting permission in Flutter:
import 'package:permission_handler/permission_handler.dart';
// Function to check and request permission
Future<void> requestPermissions() async {
// Check the status of gallery access permission
if (await Permission.photos.request().isGranted) {
// Permission granted, perform actions
print('Gallery access permission granted');
} else {
// Permission not granted, handle denial or show message
print('Gallery access permission denied');
}
}