packageManager.queryIntentActivities(intent, 0)
will return an EMPTY list if your app is running on targetSdkVersion 30
To resolve this issue you have to use <queries>
in manifest as queryIntentActivities()
are filtered based on the calling app's declaration.
Fix image capture + image upload to work with Android "scoped storage"
The issue can be related to new package visibility (https://developer.android.com/about/versions/11/privacy/package-visibility).
After all updates (at least Android Studio 4.1) try to add in your manifest the that show what action is required in your app.
In my case, the problem disappears when I add
IMAGE_CAPTURE for CAMERA, GET_CONTENT for GALLERY (to get files change mimeType if you want video), PICK for GALLERY (should change mimetype if u want video)
CHOOSER for GALLERY (if someone has other image browsers)
You can also check in logcat what queries you have to add (should contains "BLOCKED" or "no permission".
Error is because ImagePickerModule
when you don't have permission in Intent with resolveActivity
returns null
(you can comment it to check better errors in startActivityForResult
)
Add <query>
in AndroidManifest.xml
<manifest>
.....
.....
<queries>
<!-- Browser -->
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="http" />
</intent>
<!-- Camera -->
<intent>
<action android:name="android.media.action.IMAGE_CAPTURE" />
</intent>
<!-- Gallery -->
<intent>
<action android:name="android.intent.action.GET_CONTENT" />
<data android:mimeType="image/*" />
</intent>
<intent>
<action android:name="android.intent.action.PICK" />
<data android:mimeType="image/*" />
</intent>
<intent>
<action android:name="android.intent.action.CHOOSER" />
</intent>
</queries>
.....
.....
</manifest>