Android Photo Picker set tick for already selected uri's previously
Asked Answered
D

0

6

Reference to the feature -> https://developer.android.com/training/data-storage/shared/photopicker#device-availability

Code and explanation I

I create a request which will open up photo and video picker, after selecting a list of uri's is returned in the listener

    PickVisualMediaRequest request =
            new PickVisualMediaRequest.Builder()
                    .setMediaType(ActivityResultContracts.PickVisualMedia.ImageAndVideo.INSTANCE)
                    .build();
    pickVisualMediaRequestActivityResultLauncher.launch(request);

Code and explanation II

The following code registers Listener for Activity result and is executed when photos/videos are selected using Photo picker

pickVisualMediaRequestActivityResultLauncher =
                registerForActivityResult(new ActivityResultContracts.PickMultipleVisualMedia(10),
                        result -> {
                            //Handling Here what to do with result (List<Uri>)
                        }
                );

The problem is I've given the limit of 10 to mediafiles in the PickMultipleVisualMedia's constructor, user selects 5 items and comes back to locally created preview screen and then decides to select remaining 5 items then there is no way I could find to make those 5 files already selected in the photo picker, no way to pass the already selected uris to the picker function, user has to select all the 10 files again, is there any solution for this? Because I couldn't find any function in Picker class that would allow me to do so.

Dragelin answered 18/4, 2023 at 8:43 Comment(1)
Same problem here. Have been able to find any useful code?Tartar

© 2022 - 2024 — McMap. All rights reserved.