Builder
class Builder
kotlin.Any | |
↳ | android.view.textclassifier.TextClassification.Builder |
Builder for building TextClassification
objects.
e.g.
<code>TextClassification classification = new TextClassification.Builder() .setText(classifiedText) .setEntityType(TextClassifier.TYPE_EMAIL, 0.9) .setEntityType(TextClassifier.TYPE_OTHER, 0.1) .addAction(remoteAction1) .addAction(remoteAction2) .build(); </code>
Summary
Public constructors | |
---|---|
Builder() |
Public methods | |
---|---|
TextClassification.Builder |
addAction(action: RemoteAction) Adds an action that may be performed on the classified text. |
TextClassification |
build() Builds and returns a |
TextClassification.Builder |
setEntityType(type: String, confidenceScore: Float) Sets an entity type for the classification result and assigns a confidence score. |
TextClassification.Builder |
Sets the extended data. |
TextClassification.Builder |
Sets the icon for the primary action that may be rendered on a widget used to act on the classified text. |
TextClassification.Builder |
Sets an id for the TextClassification object. |
TextClassification.Builder |
Sets the intent for the primary action that may be fired to act on the classified text. |
TextClassification.Builder |
Sets the label for the primary action that may be rendered on a widget used to act on the classified text. |
TextClassification.Builder |
setOnClickListener(onClickListener: View.OnClickListener?) Sets the OnClickListener for the primary action that may be triggered to act on the classified text. |
TextClassification.Builder |
Sets the classified text. |
Public constructors
Builder
Builder()
Public methods
addAction
fun addAction(action: RemoteAction): TextClassification.Builder
Adds an action that may be performed on the classified text. Actions should be added in order of likelihood that the user will use them, with the most likely action being added first.
Parameters | |
---|---|
action |
RemoteAction: This value cannot be null . |
Return | |
---|---|
TextClassification.Builder |
This value cannot be null . |
build
fun build(): TextClassification
Builds and returns a TextClassification
object.
Return | |
---|---|
TextClassification |
This value cannot be null . |
setEntityType
fun setEntityType(
type: String,
confidenceScore: Float
): TextClassification.Builder
Sets an entity type for the classification result and assigns a confidence score. If a confidence score had already been set for the specified entity type, this will override that score.
Parameters | |
---|---|
confidenceScore |
Float: a value from 0 (low confidence) to 1 (high confidence). 0 implies the entity does not exist for the classified text. Values greater than 1 are clamped to 1. Value is between 0.0 and 1.0 inclusive |
type |
String: This value cannot be null . Value is android.view.textclassifier.TextClassifier#TYPE_UNKNOWN , android.view.textclassifier.TextClassifier#TYPE_OTHER , android.view.textclassifier.TextClassifier#TYPE_EMAIL , android.view.textclassifier.TextClassifier#TYPE_PHONE , android.view.textclassifier.TextClassifier#TYPE_ADDRESS , android.view.textclassifier.TextClassifier#TYPE_URL , android.view.textclassifier.TextClassifier#TYPE_DATE , android.view.textclassifier.TextClassifier#TYPE_DATE_TIME , android.view.textclassifier.TextClassifier#TYPE_FLIGHT_NUMBER , or android.view.textclassifier.TextClassifier.TYPE_DICTIONARY |
Return | |
---|---|
TextClassification.Builder |
This value cannot be null . |
setExtras
fun setExtras(extras: Bundle?): TextClassification.Builder
Sets the extended data.
Parameters | |
---|---|
extras |
Bundle?: This value may be null . |
Return | |
---|---|
TextClassification.Builder |
This value cannot be null . |
setIcon
funsetIcon(icon: Drawable?): TextClassification.Builder
Deprecated: Use addAction(android.app.RemoteAction)
instead.
Sets the icon for the primary action that may be rendered on a widget used to act on the classified text.
NOTE: This field is not parcelled. If read from a parcel, the returned icon represents the icon of the first RemoteAction
(if one exists).
Parameters | |
---|---|
icon |
Drawable?: This value may be null . |
Return | |
---|---|
TextClassification.Builder |
This value cannot be null . |
setId
fun setId(id: String?): TextClassification.Builder
Sets an id for the TextClassification object.
Parameters | |
---|---|
id |
String?: This value may be null . |
Return | |
---|---|
TextClassification.Builder |
This value cannot be null . |
setIntent
funsetIntent(intent: Intent?): TextClassification.Builder
Deprecated: Use addAction(android.app.RemoteAction)
instead.
Sets the intent for the primary action that may be fired to act on the classified text.
NOTE: This field is not parcelled.
Parameters | |
---|---|
intent |
Intent?: This value may be null . |
Return | |
---|---|
TextClassification.Builder |
This value cannot be null . |
setLabel
funsetLabel(label: String?): TextClassification.Builder
Deprecated: Use addAction(android.app.RemoteAction)
instead.
Sets the label for the primary action that may be rendered on a widget used to act on the classified text.
NOTE: This field is not parcelled. If read from a parcel, the returned label represents the label of the first RemoteAction
(if one exists).
Parameters | |
---|---|
label |
String?: This value may be null . |
Return | |
---|---|
TextClassification.Builder |
This value cannot be null . |
setOnClickListener
funsetOnClickListener(onClickListener: View.OnClickListener?): TextClassification.Builder
Deprecated: Use addAction(android.app.RemoteAction)
instead.
Sets the OnClickListener for the primary action that may be triggered to act on the classified text.
NOTE: This field is not parcelable. If read from a parcel, the returned OnClickListener represents the first RemoteAction
(if one exists).
Parameters | |
---|---|
onClickListener |
View.OnClickListener?: This value may be null . |
Return | |
---|---|
TextClassification.Builder |
This value cannot be null . |
setText
fun setText(text: String?): TextClassification.Builder
Sets the classified text.
Parameters | |
---|---|
text |
String?: This value may be null . |
Return | |
---|---|
TextClassification.Builder |
This value cannot be null . |