PickMultiplevisualmedia foto picker wird niemals namens ActivityResultcallback rufenAndroid

Forum für diejenigen, die für Android programmieren
Anonymous
 PickMultiplevisualmedia foto picker wird niemals namens ActivityResultcallback rufen

Post by Anonymous »

Ich versuche, "neue" Fototopfers -Google -Funktionalität zu verwenden, anstatt read_media_images < /p>
Ich habe diese Variable in meiner Fragmentklasse erstellt: < /p>
// Registers a photo picker activity launcher in multi-select mode.
private final ActivityResultLauncher mPickPhotosActivityResult =
registerForActivityResult(new ActivityResultContracts.PickMultipleVisualMedia(5), new ActivityResultCallback() {
@Override
public void onActivityResult(List uris) {
// Callback is invoked after the user selects media items or closes the
// photo picker.
// !!!!! NEVER CALLED BACKED HERE !!!!!.
if (uris.isEmpty()) {
return;
}
}
});
< /code>
Dann starten Sie das Auswählen von Foto, indem Sie auf einige Schaltflächen klicken: < /p>
// For this example, launch the photo picker and let the user choose images
// and videos. If you want the user to select a specific type of media file,
// use the overloaded versions of launch(), as shown in the section about how
// to select a single media item.
mPickPhotosActivityResult.launch(new PickVisualMediaRequest.Builder()
.setMediaType(ActivityResultContracts.PickVisualMedia.ImageOnly.INSTANCE)
.build());
< /code>
Das Dialogfeld "Foto auswählen" wird erfolgreich angezeigt, und ich kann in darin mehrfacher Fotos auswählen.>

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post