-
Notifications
You must be signed in to change notification settings - Fork 319
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add method to check if storage permission is granted #287
Comments
I wrote this wile writing some code that was using PhotoManager in the background (using workmanager It keeps giving me exception: E/MethodChannel#top.kikt/photo_manager( 5686): Failed to handle method call
E/MethodChannel#top.kikt/photo_manager( 5686): java.lang.NullPointerException: 获取权限的Activity不存在
E/MethodChannel#top.kikt/photo_manager( 5686): at top.kikt.imagescanner.permission.PermissionsUtils.getPermissionsWithTips(PermissionsUtils.java:110)
E/MethodChannel#top.kikt/photo_manager( 5686): at top.kikt.imagescanner.permission.PermissionsUtils.getPermissions(PermissionsUtils.java:95)
E/MethodChannel#top.kikt/photo_manager( 5686): at top.kikt.imagescanner.core.PhotoManagerPlugin.onMethodCall(PhotoManagerPlugin.kt:152)
E/MethodChannel#top.kikt/photo_manager( 5686): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:231)
E/MethodChannel#top.kikt/photo_manager( 5686): at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:93)
E/MethodChannel#top.kikt/photo_manager( 5686): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:642)
E/MethodChannel#top.kikt/photo_manager( 5686): at android.os.MessageQueue.nativePollOnce(Native Method)
E/MethodChannel#top.kikt/photo_manager( 5686): at android.os.MessageQueue.next(MessageQueue.java:326)
E/MethodChannel#top.kikt/photo_manager( 5686): at android.os.Looper.loop(Looper.java:160)
E/MethodChannel#top.kikt/photo_manager( 5686): at android.app.ActivityThread.main(ActivityThread.java:6718)
E/MethodChannel#top.kikt/photo_manager( 5686): at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#top.kikt/photo_manager( 5686): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:491)
E/MethodChannel#top.kikt/photo_manager( 5686): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858) At first, I thought that it's because I don't have a permission
But it looks like you specifically use some activity when checking for permission. |
Unfortunately, you must have an Activity instance to apply for runtime permissions. |
I just tested this with If this is just a thing of checking permission, we can just use permission_handler plugin, and everything will work! |
I have the same error. I am using workmanager and PhotoManager and I need to process some photos in background and I have this error
And this is my code
Is there any way to use PhotoManager in background? |
I resolved the issue using |
Do other functions work? Like, actually getting images? |
@TheLastGimbus I use |
And... it works? Without the app in the foreground whatsoever? Also, I'm not recently in touch with my project that used this library - I would be really grateful if you could quickly check if some other functions work 🙏❤️ |
Yes. So far it works. I process images in the background using those two libraries. With the application in the foreground, the process works completely to finish but when I close the application the process only take approximately 55 seconds and them is cancelled, but I think it was a change in the code that I made. Right now I don't have my code at my disposal but as soon as I can I can verify what you ask me. 👍 |
Ok. I check if other function work and... (drumroll)... it works.
|
@alejandrogiubel I've tried doing like this, is this the right way? await PhotoManager.setIgnorePermissionCheck(true);
List<AssetPathEntity> list = await PhotoManager.getAssetPathList(type: RequestType.image); but it still prompt me this permission dialog, how can I stop this dialog from showing every time when user only choose selected photos to be accessed? |
Maybe you didn't |
@TheLastGimbus Oops, sorry I accidentally removed it when I was doing screenshot, actually I was having the same issue with |
Permissions would be dynamic checking things, so I guess the most proper way is to use the request method instead? |
There are multiple requests/features involved in the whole discussion, if anyone have questions other than the |
If anyone is finding this issue because they have the same problem as @danielseow-simplify the solution is to add |
We already have
PhotoManager.requestPermission()
for getting permission.It would be nice to have method to check if permission is granted.
The text was updated successfully, but these errors were encountered: