SerializeOptions

open class SerializeOptions
kotlin.Any
   ↳ androidx.slice.SliceUtils.SerializeOptions

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

Summary

Constants

static Int

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

static Int

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

static Int

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

Public constructors

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

Public methods

open SliceUtils.SerializeOptions!

Sets how android.app.slice.SliceItem#FORMAT_ACTION items should be handled.

open SliceUtils.SerializeOptions!

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

open SliceUtils.SerializeOptions!

Sets how android.app.slice.SliceItem#FORMAT_IMAGE items should be handled.

open SliceUtils.SerializeOptions!

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

open SliceUtils.SerializeOptions!

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

Constants

MODE_CONVERT

static val MODE_CONVERT: Int

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.

Value: 2

MODE_REMOVE

static val MODE_REMOVE: Int

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

Value: 1

MODE_THROW

static val MODE_THROW: Int

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

Value: 0

Public constructors

<init>

SerializeOptions()

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

Public methods

setActionMode

open fun setActionMode(mode: Int): SliceUtils.SerializeOptions!

Sets how android.app.slice.SliceItem#FORMAT_ACTION items should be handled. The default mode is MODE_THROW.

Parameters
mode Int: The desired mode.

setImageConversionFormat

open fun setImageConversionFormat(format: CompressFormat!, quality: Int): SliceUtils.SerializeOptions!

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

Parameters
format CompressFormat!: The format to encode images with, default is android.graphics.Bitmap.CompressFormat#PNG.
quality CompressFormat!: The quality to use when encoding images.

setImageMode

open fun setImageMode(mode: Int): SliceUtils.SerializeOptions!

Sets how android.app.slice.SliceItem#FORMAT_IMAGE items should be handled. The default mode is MODE_THROW.

Parameters
mode Int: The desired mode.

setMaxImageHeight

open fun setMaxImageHeight(height: Int): SliceUtils.SerializeOptions!

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.

setMaxImageWidth

open fun setMaxImageWidth(width: Int): SliceUtils.SerializeOptions!

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.