Composable Function
Android
@Composable
public fun CheckBox(
    checked: Boolean,
    onCheckedChange: Action?,
    modifier: GlanceModifier = GlanceModifier,
    text: String = "",
    style: TextStyle? = null,
    colors: CheckBoxColors = CheckboxDefaults.colors(),
    maxLines: Int = Int.MAX_VALUE,
): Unit

Adds a check box view to the glance view.

Parameters

checked whether the check box is checked
onCheckedChange the action to be run when the checkbox is clicked. The current value of checked is provided to this action in its ActionParameters, and can be retrieved using the ToggleableStateKey. If this action launches an activity, the current value of checked will be passed as an intent extra with the name RemoteViews.EXTRA_CHECKED. In order to allow the Launcher to provide this extra on Android version S and later, we use a mutable PendingIntent (android.app.PendingIntent.FLAG_MUTABLE) when this action is not a lambda. Before S, and for lambda actions, this will be an immutable PendingIntent.
modifier the modifier to apply to the check box
text the text to display to the end of the check box
style the style to apply to text
colors the color tint to apply to the check box
maxLines An optional maximum number of lines for the text to span, wrapping if necessary. If the text exceeds the given number of lines, it will be truncated.
Android
@Composable
public fun CheckBox(
    checked: Boolean,
    onCheckedChange: () -> Unit,
    modifier: GlanceModifier = GlanceModifier,
    text: String = "",
    style: TextStyle? = null,
    colors: CheckBoxColors = CheckboxDefaults.colors(),
    maxLines: Int = Int.MAX_VALUE,
): Unit

Adds a check box view to the glance view.

Parameters

checked whether the check box is checked
onCheckedChange the action to be run when the checkbox is clicked
modifier the modifier to apply to the check box
text the text to display to the end of the check box
style the style to apply to text
colors the color tint to apply to the check box
maxLines An optional maximum number of lines for the text to span, wrapping if necessary. If the text exceeds the given number of lines, it will be truncated.
Android
@ExperimentalGlanceApi
@Composable
public fun CheckBox(
    checked: Boolean,
    onCheckedChange: () -> Unit,
    modifier: GlanceModifier = GlanceModifier,
    text: String = "",
    style: TextStyle? = null,
    colors: CheckBoxColors = CheckboxDefaults.colors(),
    maxLines: Int = Int.MAX_VALUE,
    key: String? = null,
): Unit

Adds a check box view to the glance view.

Parameters

checked whether the check box is checked
onCheckedChange the action to be run when the checkbox is clicked
modifier the modifier to apply to the check box
text the text to display to the end of the check box
style the style to apply to text
colors the color tint to apply to the check box
maxLines An optional maximum number of lines for the text to span, wrapping if necessary. If the text exceeds the given number of lines, it will be truncated.
key A stable and unique key that identifies the action for this checkbox. This ensures that the correct action is triggered, especially in cases of items that change order. If not provided we use the key that is automatically generated by the Compose runtime, which is unique for every exact code location in the composition tree.