MediaPicker — Native Android Media Picker Extension

MediaPicker — Android Media Picker Extension

MediaPicker is a lightweight Android media picker extension for Niotron and MIT App Inventor that makes it easy to select images and videos using Android's native picker system.

It is designed with performance, memory usage, WebView compatibility, and low-end devices in mind.

:sparkles: Features

:camera_with_flash: Image Picker
Pick images using the native Android Photo Picker.

:movie_camera: Video Picker
Select videos from the device.

:framed_picture: Image + Video Picker
Pick both images and videos from a single picker.

:mobile_phone: Android 13+ Photo Picker
Uses the system Photo Picker on Android 13+ when available.

:counterclockwise_arrows_button: Automatic Fallback
Falls back to ACTION_OPEN_DOCUMENT and ACTION_GET_CONTENT when the Photo Picker isn't available.

:books: Multiple Selection
Supports selecting multiple media files where the system picker allows it.

:high_voltage: Background Processing
Image decoding, compression, file copying and Base64 processing run off the UI thread to keep the app responsive.

:brain: Memory Optimized
Images are decoded at an appropriate sample size, while videos and other raw files are streamed directly to disk instead of being loaded completely into memory.

:clamp: Image Compression
Resize and compress selected images with configurable quality.

:triangular_ruler: Image Resizing
Set a maximum image dimension while preserving the aspect ratio.

:counterclockwise_arrows_button: EXIF Rotation
Automatically corrects image orientation using EXIF metadata.

:framed_picture: JPEG / PNG / WEBP
Choose the output format for processed images.

:1234: Optional Base64
Get media as Base64 when needed, including ready-to-use data URLs for WebView applications.

:file_folder: Local File Path
Returns a real local cache file path for the selected media.

:package: File Metadata
Returns file name, extension, MIME type and file size.

:prohibited: File Size Protection
Reject oversized source files using a configurable maximum file size.

:floppy_disk: Base64 Size Limit
Optionally limit Base64 generation for large files to avoid unnecessary memory usage.

:broom: Cache Management
Clear all files created by the extension, check cache size, or delete an individual cached file.

:hourglass_not_done: Processing Progress
Events are available to track multi-file processing progress.

:shield: Safe Re-entry Protection
Prevents multiple picker operations from running simultaneously.

Built with Java + Fast Cli


:puzzle_piece: Blocks

Media Picking

  1. PickImage()
    Opens the picker restricted to images.

  2. PickVideo()
    Opens the picker restricted to videos.

  3. PickMedia()
    Opens the picker for images and videos.

  4. AllowMultiple
    Enables multiple media selection where supported by the picker.


:gear: Image Processing

  1. CompressionQuality
    Sets image compression quality from 1–100.

  2. MaxImageDimension
    Sets the maximum width/height for processed images.

  3. OutputFormat
    Selects JPEG, PNG, or WEBP.


:1234: Base64

  1. IncludeBase64
    Enables or disables Base64 output.

  2. MaxBase64SizeMB
    Sets the maximum file size for Base64 generation.


:package: File Protection

  1. MaxFileSizeMB
    Sets the maximum allowed source file size.

  2. IsProcessing
    Returns whether a media pick/processing operation is currently running.


:broom: Cache

  1. ClearCache()
    Deletes all cached files created by the extension.

  2. GetCacheSizeMB()
    Returns the total cache size used by the extension.

  3. DeleteCachedFile(path)
    Deletes a specific cached file returned by the extension.

  4. AutoClearCacheBeforePick
    Automatically clears previous picker cache before starting a new pick.


:satellite_antenna: Events

MediaPicked — Fired after a single media file has been successfully processed.

Returns:

  • File path

  • Base64

  • MIME type

  • File name

  • File extension

  • File size

MultipleMediaPicked — Fired when multiple media files are selected.

Returns lists of:

  • Paths

  • Base64 values

  • MIME types

  • File names

  • Extensions

  • File sizes

MediaPickCancelled — Fired when the user cancels the picker.

MediaPickError — Fired when selected media cannot be processed.

MediaProcessingStarted — Fired when background processing begins.

MediaProcessingProgress — Reports completed files and total files during multi-selection.

MediaPickTooLarge — Fired when a selected file exceeds MaxFileSizeMB.

CacheCleared — Fired after the extension clears its cached files.


:globe_with_meridians: Perfect for WebView Apps

MediaPicker is especially useful for HTML/WebView based apps where you want to use the native Android media picker while receiving a local file path or Base64 content that can be passed directly to your WebView.

For example, the returned Base64 can be used as:

data:<mimeType>;base64,<base64>

while the returned local path can be used when your WebView workflow requires an actual file.


:inbox_tray: Download

MediaPicker Extension:

com.zebdroid.mediapicker.aix (23.3 KB)


:mobile_phone: Compatibility

Designed for modern Android devices with automatic fallback support for older Android versions and devices where the system Photo Picker is unavailable.


How do you copy/move an image from the path to the ASD, using the File component ?

Why save picked images to the generally inaccessible location you have chosen, why not just create a directory in the ASD?

I noticed that your extension was built using FAST-CLI v7.0.0 07.08.26.23.38, but unfortunately, you mentioned Rush.

2 Likes

1 Like

I'm really really sorry :pensive_face:..

1 Like