Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Ctors](https://developer.android.com/reference/android/view/textclassifier/TextClassification.Builder#pubctors) \| [Methods](https://developer.android.com/reference/android/view/textclassifier/TextClassification.Builder#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/view/textclassifier/TextClassification.Builder#inhmethods)

# TextClassification.Builder

*** ** * ** ***

` public static final class TextClassification.Builder `   
` extends https://developer.android.com/reference/java/lang/Object ` ` `

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.view.textclassifier.TextClassification.Builder |

<br />

*** ** * ** ***

Builder for building `https://developer.android.com/reference/android/view/textclassifier/TextClassification` objects.

e.g.

    TextClassification classification = new TextClassification.Builder()
             .setText(classifiedText)
             .setEntityType(TextClassifier.TYPE_EMAIL, 0.9)
             .setEntityType(TextClassifier.TYPE_OTHER, 0.1)
             .addAction(remoteAction1)
             .addAction(remoteAction2)
             .build();

<br />

## Summary

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/view/textclassifier/TextClassification.Builder#Builder()() ` |

| ### Public methods ||
|---|---|
| ` https://developer.android.com/reference/android/view/textclassifier/TextClassification.Builder` | ` https://developer.android.com/reference/android/view/textclassifier/TextClassification.Builder#addAction(android.app.RemoteAction)(https://developer.android.com/reference/android/app/RemoteAction action) ` Adds an action that may be performed on the classified text. |
| ` https://developer.android.com/reference/android/view/textclassifier/TextClassification` | ` https://developer.android.com/reference/android/view/textclassifier/TextClassification.Builder#build()() ` Builds and returns a `https://developer.android.com/reference/android/view/textclassifier/TextClassification` object. |
| ` https://developer.android.com/reference/android/view/textclassifier/TextClassification.Builder` | ` https://developer.android.com/reference/android/view/textclassifier/TextClassification.Builder#setEntityType(java.lang.String,%20float)(https://developer.android.com/reference/java/lang/String type, float confidenceScore) ` Sets an entity type for the classification result and assigns a confidence score. |
| ` https://developer.android.com/reference/android/view/textclassifier/TextClassification.Builder` | ` https://developer.android.com/reference/android/view/textclassifier/TextClassification.Builder#setExtras(android.os.Bundle)(https://developer.android.com/reference/android/os/Bundle extras) ` Sets the extended data. |
| ` https://developer.android.com/reference/android/view/textclassifier/TextClassification.Builder` | ` https://developer.android.com/reference/android/view/textclassifier/TextClassification.Builder#setIcon(android.graphics.drawable.Drawable)(https://developer.android.com/reference/android/graphics/drawable/Drawable icon) ` *This method was deprecated in API level 28. Use `https://developer.android.com/reference/android/view/textclassifier/TextClassification.Builder#addAction(android.app.RemoteAction)` instead.* |
| ` https://developer.android.com/reference/android/view/textclassifier/TextClassification.Builder` | ` https://developer.android.com/reference/android/view/textclassifier/TextClassification.Builder#setId(java.lang.String)(https://developer.android.com/reference/java/lang/String id) ` Sets an id for the TextClassification object. |
| ` https://developer.android.com/reference/android/view/textclassifier/TextClassification.Builder` | ` https://developer.android.com/reference/android/view/textclassifier/TextClassification.Builder#setIntent(android.content.Intent)(https://developer.android.com/reference/android/content/Intent intent) ` *This method was deprecated in API level 28. Use `https://developer.android.com/reference/android/view/textclassifier/TextClassification.Builder#addAction(android.app.RemoteAction)` instead.* |
| ` https://developer.android.com/reference/android/view/textclassifier/TextClassification.Builder` | ` https://developer.android.com/reference/android/view/textclassifier/TextClassification.Builder#setLabel(java.lang.String)(https://developer.android.com/reference/java/lang/String label) ` *This method was deprecated in API level 28. Use `https://developer.android.com/reference/android/view/textclassifier/TextClassification.Builder#addAction(android.app.RemoteAction)` instead.* |
| ` https://developer.android.com/reference/android/view/textclassifier/TextClassification.Builder` | ` https://developer.android.com/reference/android/view/textclassifier/TextClassification.Builder#setOnClickListener(android.view.View.OnClickListener)(https://developer.android.com/reference/android/view/View.OnClickListener onClickListener) ` *This method was deprecated in API level 28. Use `https://developer.android.com/reference/android/view/textclassifier/TextClassification.Builder#addAction(android.app.RemoteAction)` instead.* |
| ` https://developer.android.com/reference/android/view/textclassifier/TextClassification.Builder` | ` https://developer.android.com/reference/android/view/textclassifier/TextClassification.Builder#setText(java.lang.String)(https://developer.android.com/reference/java/lang/String text) ` Sets the classified text. |

### Inherited methods

From class ` https://developer.android.com/reference/java/lang/Object ` ` https://developer.android.com/reference/java/lang/Object` ` https://developer.android.com/reference/java/lang/Object#clone()() `

Creates and returns a copy of this object.
` boolean` ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) `

Indicates whether some other object is "equal to" this one.
` void` ` https://developer.android.com/reference/java/lang/Object#finalize()() `

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
` final https://developer.android.com/reference/java/lang/Class<?>` ` https://developer.android.com/reference/java/lang/Object#getClass()() `

Returns the runtime class of this `Object`.
` int` ` https://developer.android.com/reference/java/lang/Object#hashCode()() `

Returns a hash code value for the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#notify()() `

Wakes up a single thread that is waiting on this object's monitor.
` final void` ` https://developer.android.com/reference/java/lang/Object#notifyAll()() `

Wakes up all threads that are waiting on this object's monitor.
` https://developer.android.com/reference/java/lang/String` ` https://developer.android.com/reference/java/lang/Object#toString()() `

Returns a string representation of the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait()() `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*.

## Public constructors

### Builder

```
public Builder ()
```

<br />

<br />

## Public methods

### addAction

Added in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public TextClassification.Builder addAction (RemoteAction action)
```

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.

<br />

| Parameters ||
|---|---|
| `action` | `RemoteAction`: This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/textclassifier/TextClassification.Builder` | This value cannot be `null`. <br /> |

### build

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public TextClassification build ()
```

Builds and returns a `https://developer.android.com/reference/android/view/textclassifier/TextClassification` object.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/textclassifier/TextClassification` | This value cannot be `null`. <br /> |

### setEntityType

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public TextClassification.Builder setEntityType (String type, 
                float confidenceScore)
```

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.

<br />

| Parameters ||
|---|---|
| `type` | `String`: This value cannot be `null`. Value is one of the following: - `https://developer.android.com/reference/android/view/textclassifier/TextClassifier#TYPE_UNKNOWN` - `https://developer.android.com/reference/android/view/textclassifier/TextClassifier#TYPE_OTHER` - `https://developer.android.com/reference/android/view/textclassifier/TextClassifier#TYPE_EMAIL` - `https://developer.android.com/reference/android/view/textclassifier/TextClassifier#TYPE_PHONE` - `https://developer.android.com/reference/android/view/textclassifier/TextClassifier#TYPE_ADDRESS` - `https://developer.android.com/reference/android/view/textclassifier/TextClassifier#TYPE_URL` - `https://developer.android.com/reference/android/view/textclassifier/TextClassifier#TYPE_DATE` - `https://developer.android.com/reference/android/view/textclassifier/TextClassifier#TYPE_DATE_TIME` - `https://developer.android.com/reference/android/view/textclassifier/TextClassifier#TYPE_FLIGHT_NUMBER` - `https://developer.android.com/reference/android/view/textclassifier/TextClassifier#TYPE_OTP` - `https://developer.android.com/reference/android/view/textclassifier/TextClassifier#TYPE_SMS_RETRIEVER_OTP` - `https://developer.android.com/reference/android/view/textclassifier/TextClassifier#TYPE_SMS_WEB_OTP` |
| `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.0f and 1.0f inclusive <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/textclassifier/TextClassification.Builder` | This value cannot be `null`. <br /> |

### setExtras

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public TextClassification.Builder setExtras (Bundle extras)
```

Sets the extended data.

<br />

| Parameters ||
|---|---|
| `extras` | `Bundle`: This value may be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/textclassifier/TextClassification.Builder` | This value cannot be `null`. <br /> |

### setIcon

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public TextClassification.Builder setIcon (Drawable icon)
```

<br />

**This method was deprecated in API level 28.**   

Use `https://developer.android.com/reference/android/view/textclassifier/TextClassification.Builder#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 `https://developer.android.com/reference/android/app/RemoteAction` (if one exists).

<br />

| Parameters ||
|---|---|
| `icon` | `Drawable`: This value may be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/textclassifier/TextClassification.Builder` | This value cannot be `null`. <br /> |

### setId

Added in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public TextClassification.Builder setId (String id)
```

Sets an id for the TextClassification object.

<br />

| Parameters ||
|---|---|
| `id` | `String`: This value may be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/textclassifier/TextClassification.Builder` | This value cannot be `null`. <br /> |

### setIntent

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public TextClassification.Builder setIntent (Intent intent)
```

<br />

**This method was deprecated in API level 28.**   

Use `https://developer.android.com/reference/android/view/textclassifier/TextClassification.Builder#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.

<br />

| Parameters ||
|---|---|
| `intent` | `Intent`: This value may be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/textclassifier/TextClassification.Builder` | This value cannot be `null`. <br /> |

### setLabel

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public TextClassification.Builder setLabel (String label)
```

<br />

**This method was deprecated in API level 28.**   

Use `https://developer.android.com/reference/android/view/textclassifier/TextClassification.Builder#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 `https://developer.android.com/reference/android/app/RemoteAction` (if one exists).

<br />

| Parameters ||
|---|---|
| `label` | `String`: This value may be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/textclassifier/TextClassification.Builder` | This value cannot be `null`. <br /> |

### setOnClickListener

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public TextClassification.Builder setOnClickListener (View.OnClickListener onClickListener)
```

<br />

**This method was deprecated in API level 28.**   

Use `https://developer.android.com/reference/android/view/textclassifier/TextClassification.Builder#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 `https://developer.android.com/reference/android/app/RemoteAction` (if one exists).

<br />

| Parameters ||
|---|---|
| `onClickListener` | `View.OnClickListener`: This value may be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/textclassifier/TextClassification.Builder` | This value cannot be `null`. <br /> |

### setText

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public TextClassification.Builder setText (String text)
```

Sets the classified text.

<br />

| Parameters ||
|---|---|
| `text` | `String`: This value may be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/textclassifier/TextClassification.Builder` | This value cannot be `null`. <br /> |