Image Preloading (Android)
Android widgets have limitations when it comes to displaying remote images directly. The image preloading API allows you to download images to the app's cache directory, making them available to your widgets via a local FileProvider.
Overview
The image preloading system on Android works by:
- Downloading images from URLs to the internal app cache.
- Making these images available to Voltra widgets via the
assetNameproperty. - Providing APIs to reload widgets when new images are ready.
API Reference
preloadImages(images: PreloadImageOptions[]): Promise<PreloadImagesResult>
Downloads images to the Android cache for use in Widgets.
Example:
reloadWidgets(widgetIds?: string[]): Promise<void>
Reloads Android widgets to pick up newly preloaded images. If no widgetIds are provided, all active widgets will be reloaded.
clearPreloadedImages(keys?: string[]): Promise<void>
Removes preloaded images from the Android cache. If no keys are provided, all preloaded images will be cleared.
Usage in Android Widgets
Once images are preloaded, reference them using the assetName property in the VoltraAndroid.Image component:
