SliceUtils.SerializeOptions

public static class SliceUtils.SerializeOptions
extends Object

java.lang.Object
   ↳ androidx.slice.SliceUtils.SerializeOptions


Holds options for how to handle SliceItems that cannot be serialized.

Summary

Constants

int MODE_CONVERT

Constant indicating that the SliceItem should be serialized as much as possible.

int MODE_REMOVE

Constant indicating that the SliceItem should be removed when this format is encountered.

int MODE_THROW

Constant indicating that the an IllegalArgumentException should be thrown when this format is encountered.

Public constructors

SliceUtils.SerializeOptions()

Public methods

SliceUtils.SerializeOptions setActionMode(int mode)

Sets how SliceItem.FORMAT_ACTION items should be handled.

SliceUtils.SerializeOptions setImageConversionFormat(Bitmap.CompressFormat format, int quality)

Sets the options to use when converting icons to be serialized.

SliceUtils.SerializeOptions setImageMode(int mode)

Sets how SliceItem.FORMAT_IMAGE items should be handled.

SliceUtils.SerializeOptions setMaxImageHeight(int height)

Set the maximum height of an image to use when serializing.

SliceUtils.SerializeOptions setMaxImageWidth(int width)

Set the maximum width of an image to use when serializing.

Inherited methods

Constants

MODE_CONVERT

public static final int MODE_CONVERT

Constant indicating that the SliceItem should be serialized as much as possible.

For images this means they will be attempted to be serialized. For actions, the action will be removed but the content of the action will be serialized. The action may be triggered later on a de-serialized slice by binding the slice again and activating a pending-intent at the same location as the serialized action.

Constant Value: 2 (0x00000002)

MODE_REMOVE

public static final int MODE_REMOVE

Constant indicating that the SliceItem should be removed when this format is encountered.

Constant Value: 1 (0x00000001)

MODE_THROW

public static final int MODE_THROW

Constant indicating that the an IllegalArgumentException should be thrown when this format is encountered.

Constant Value: 0 (0x00000000)

Public constructors

SliceUtils.SerializeOptions

public SliceUtils.SerializeOptions ()

Public methods

setActionMode

public SliceUtils.SerializeOptions setActionMode (int mode)

Sets how SliceItem.FORMAT_ACTION items should be handled. The default mode is MODE_THROW.

Parameters
mode int: The desired mode.

Returns
SliceUtils.SerializeOptions

setImageConversionFormat

public SliceUtils.SerializeOptions setImageConversionFormat (Bitmap.CompressFormat format, 
                int quality)

Sets the options to use when converting icons to be serialized. Only used if the image mode is set to MODE_CONVERT.

Parameters
format Bitmap.CompressFormat: The format to encode images with, default is Bitmap.CompressFormat.PNG.

quality int: The quality to use when encoding images.

Returns
SliceUtils.SerializeOptions

setImageMode

public SliceUtils.SerializeOptions setImageMode (int mode)

Sets how SliceItem.FORMAT_IMAGE items should be handled. The default mode is MODE_THROW.

Parameters
mode int: The desired mode.

Returns
SliceUtils.SerializeOptions

setMaxImageHeight

public SliceUtils.SerializeOptions setMaxImageHeight (int height)

Set the maximum height of an image to use when serializing.

Will only be used if the setImageMode(int) is set to MODE_CONVERT. Any images larger than the maximum size will be scaled down to fit within that size. The default value is 1000.

Parameters
height int

Returns
SliceUtils.SerializeOptions

setMaxImageWidth

public SliceUtils.SerializeOptions setMaxImageWidth (int width)

Set the maximum width of an image to use when serializing.

Will only be used if the setImageMode(int) is set to MODE_CONVERT. Any images larger than the maximum size will be scaled down to fit within that size. The default value is 1000.

Parameters
width int

Returns
SliceUtils.SerializeOptions