Reputation: 11
I'm using package images_picker and update platform to sdk 33, I had update permission in my app and lib also but this is not working. The extension throw popup "Read memory card access denied" seems like permission not grantted, but i check in app info had permissions access photo and image.
this is all permisson i denfine in manifest link
and when app run first time i request permissions + action access all file: link
then when i pick image/video the result is "Read memory card access denied" link
flutter doctor:
[✓] Flutter (Channel stable, 2.10.0, on macOS 12.5.1 21G83 darwin-arm, locale en-VN)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 13.4.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.2)
[✓] VS Code (version 1.71.2)
[✓] Connected device (4 available)
[✓] HTTP Host Availability
• No issues found!
Upvotes: 1
Views: 3538
Reputation: 33
Accessing images and videos from gallery/camera will be same in Android 13 as we get in iOS device with flutter,
class MyPermissionHandler {
static Future<bool> checkPermission(
BuildContext context, {
String permissionName = 'gallery',
}) async {
if (Platform.isAndroid) {
final androidInfo = await DeviceInfoPlugin().androidInfo;
final sdkInt = androidInfo.version.sdkInt;
if (sdkInt < 33 && permissionName == 'gallery') {
return true;
}
}
FocusScope.of(context).requestFocus(FocusNode());
Map<Permission, PermissionStatus> statues;
switch (permissionName) {
case 'camera':
{
statues = await [Permission.camera].request();
PermissionStatus? statusCamera = statues[Permission.camera];
if (statusCamera == PermissionStatus.granted) {
return true;
} else if (statusCamera == PermissionStatus.permanentlyDenied) {
showPermissionDialog(context, permissionName);
return false;
} else {
return false;
}
}
case 'gallery':
{
statues = await [Permission.photos].request();
PermissionStatus? statusPhotos = statues[Permission.photos];
if (statusPhotos == PermissionStatus.granted) {
return true;
} else if (statusPhotos == PermissionStatus.permanentlyDenied) {
showPermissionDialog(context, permissionName);
return false;
} else if (statusPhotos == PermissionStatus.limited) {
showLimitedPermissionDialog(context, permissionName);
return false;
} else {
return false;
}
}
}
return false;
}
If will first request, if the user denies it will ask again to get access, but then after the user reject access permission 2nd time, you need to show the showDialog
pop-up to open the setting and give access from the settings.
One more thing, the android version which is less than 13 will check with package device info import 'package:device_info/device_info.dart';
device info, previous device will be same and updated will be act like that.
if (Platform.isAndroid) {
final androidInfo = await DeviceInfoPlugin().androidInfo;
final sdkInt = androidInfo.version.sdkInt;
if (sdkInt < 33 && permissionName == 'gallery') {
return true;
}
}
Upvotes: 2