Expand Minimize Picture-in-picture Power Device Status Voice Recognition Skip Back Skip Forward Minus Plus Play Search
Internet Explorer alert
This browser is not recommended for use with smartdevicelink.com, and may not function properly. Upgrade to a different browser to guarantee support of all features.
close alert
To Top Created with Sketch. To Top
To Bottom Created with Sketch. To Bottom
Android Guides
Uploading Images

Uploading Images

Note

If you are looking to upload images for use in template graphics, soft buttons, or the menu, you can use the ScreenManager. Other situations, such as VR help lists and turn by turn directions, are not currently covered by the ScreenManager.

You should be aware of these four things when using images in your SDL app:

  1. You may be connected to a head unit that does not have the ability to display images.
  2. You must upload images from your mobile device to the head unit before using them in a template.
  3. Persistent images are stored on a head unit between sessions. Ephemeral images are destroyed when a session ends (i.e. when the user turns off their vehicle).
  4. Images can not be uploaded when the app's hmiLevel is NONE. For more information about permissions, please review Understanding Permissions.

To learn how to use images once they are uploaded, please see Text, Images, and Buttons.

Checking if Graphics are Supported

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, use the getCapability() method of a valid SystemCapabilityManager obtained from sdlManager.getSystemCapabilityManager() to find out the display capabilities of the head unit.

sdlManager.getSystemCapabilityManager().getCapability(SystemCapabilityType.DISPLAY, new OnSystemCapabilityListener(){

   @Override
   public void onCapabilityRetrieved(Object capability){
      DisplayCapabilities dispCapability = (DisplayCapabilities) capability;
      boolean graphicsSupported = dispCapability.getGraphicSupported();
   }

   @Override
   public void onError(String info){
      Log.i(TAG, "Capability could not be retrieved: "+ info);
   }
 });

Uploading an Image Using SDL FileManager

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 SdlArtworkobject. Both SdlFiles and SdlArtworks can be created with a Uri, byte[], or resourceId.

SdlArtwork artwork = new SdlArtwork("image_name", FileType.GRAPHIC_PNG, <image byte[]>, false);
sdlManager.getFileManager().uploadFile(artwork, new CompletionListener() {
    @Override
    public void onComplete(boolean success) {
        if (success){
            <#Image Upload Successful#>
        }
    }
});

Batch File Uploads, Persistence, etc.

Similar to other files, artworks can be persistent, batched, overwrite, etc. See Uploading Files for more information.

View on GitHub.com
Previous Section Next Section