If you use the ScreenManager
, image uploading for template graphics, soft buttons, and menu items is handled for you behind the scenes. However, you will still need to manually upload your images if you need images in an alert, VR help lists, turn-by-turn directions, or other features not currently covered by the ScreenManager
.
You should be aware of these four things when using images in your SDL app:
hmiLevel
is NONE
. For more information about permissions, please review Understanding Permissions.Before uploading images to a head unit you should first check if the head unit supports graphics. If not, you should avoid uploading unnecessary image data. To check if graphics are supported, check the getCapability()
method of a valid SystemCapabilityManager
obtained from sdlManager.getSystemCapabilityManager()
to find out the display capabilities of the head unit.
List<ImageField> imageFields = sdlManager.getSystemCapabilityManager().getDefaultMainWindowCapability().getImageFields(); boolean imagesSuported = (imageFields.size() > 0);
The FileManager
uploads files and keeps track of all the uploaded files names during a session. To send data with the FileManager
, you need to create either a SdlFile
or SdlArtwork
object. Both SdlFile
s and SdlArtwork
s can be created with a Uri
, byte[]
, or resourceId
.
SdlArtwork artwork = new SdlArtwork("image_name", FileType.GRAPHIC_PNG, image, false); sdlManager.getFileManager().uploadFile(artwork, new CompletionListener() { @Override public void onComplete(boolean success) { if (success){ // Image Upload Successful } } });
Similar to other files, artworks can be persistent, batched, overwrite, etc. See Uploading Files for more information.
View on GitHub.com