Is there any valid solution for picking image from gallery and storage having Android 10 or Android 11.I have tried many solutions but none of them is working.Whenever I got result in OnActivity result uri.getData() gives me wrong path not having proper file path.Uri not giving valid image path.
Asked
Active
Viewed 2,716 times
4
-
2There is no "file path", as the user does not need to choose a file, let alone one that your app can access. Please use the `Uri` itself, such as with `ContentResolver` and `openInputStream()`. – CommonsWare Oct 31 '20 at 18:38
-
@CommonsWare How we can compress these Uri? before uploading to server, as raw files will take much bandwidth to upload? one option i can see it copy them to internal storage then compress that? is there any other ways? thanks in advance for the help you are giving to developer community. – Anshul Kabra May 03 '21 at 13:47
-
@AnshulKabra: "How we can compress these Uri?" -- image formats that users are likely to pick (e.g., PNG, JPEG) are already compressed. Use something like [the various `ImageStreamRequestBody` implementations](https://stackoverflow.com/a/56308643/115145) to stream the content to the server. – CommonsWare May 03 '21 at 14:24