Using GalleryPicker
GalleryPicker opens the gallery picker and returns the selected image name plus the image file itself.
Use it when you need to let the user choose an existing image from the device.
Basic flow
- Open the picker with
GalleryPicker.open(...). - Read the
imageNameandimageFilevalues inonSuccess. - Use the returned
Fileas needed in your logic.
Example
GalleryPicker.open(new GalleryPicker.Listener() {
public void onSuccess(String imageName, File imageFile) {
Terminal.log(imageName);
Terminal.log(imageFile.getAbsolutePath());
}
public void onCancel() {
Terminal.log("Gallery picker cancelled");
}
public void onError(String error) {
Terminal.log(error);
}
});
Notes
onSuccessreceives the image name and the selected file.onCancelruns when the user closes the picker without choosing an image.onErrorruns when the picker cannot complete the operation.