# FontsContract.FontRequestCallback

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Deprecated in[API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Summary:[Constants](https://developer.android.com/reference/android/provider/FontsContract.FontRequestCallback#constants)\|[Ctors](https://developer.android.com/reference/android/provider/FontsContract.FontRequestCallback#pubctors)\|[Methods](https://developer.android.com/reference/android/provider/FontsContract.FontRequestCallback#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/android/provider/FontsContract.FontRequestCallback#inhmethods)  

# FontsContract.FontRequestCallback

*** ** * ** ***

[Kotlin](https://developer.android.com/reference/kotlin/android/provider/FontsContract.FontRequestCallback "View this page in Kotlin")\|Java

`
public
static


class
FontsContract.FontRequestCallback
`  
`

extends `[Object](https://developer.android.com/reference/java/lang/Object)`


``


`

|---|----------------------------------------------------|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.provider.FontsContract.FontRequestCallback |

<br />

*** ** * ** ***

<br />

**This class was deprecated in API level 31.**   
Use the[FontsContractCompat.FontRequestCallback](https://developer.android.com/reference/androidx/core/provider/FontsContractCompat.FontRequestCallback.html)for consistent behavior across all devices

Interface used to receive asynchronously fetched typefaces.

## Summary

|                                                                                                                                                                                                                        ### Constants                                                                                                                                                                                                                         ||
|-------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `int` | [FAIL_REASON_FONT_LOAD_ERROR](https://developer.android.com/reference/android/provider/FontsContract.FontRequestCallback#FAIL_REASON_FONT_LOAD_ERROR) Constant returned by[onTypefaceRequestFailed(int)](https://developer.android.com/reference/android/provider/FontsContract.FontRequestCallback#onTypefaceRequestFailed(int))signaling that the font returned by the provider was not loaded properly.                                            |
| `int` | [FAIL_REASON_FONT_NOT_FOUND](https://developer.android.com/reference/android/provider/FontsContract.FontRequestCallback#FAIL_REASON_FONT_NOT_FOUND) Constant returned by[onTypefaceRequestFailed(int)](https://developer.android.com/reference/android/provider/FontsContract.FontRequestCallback#onTypefaceRequestFailed(int))signaling that the font provider did not return any results for the given query.                                       |
| `int` | [FAIL_REASON_FONT_UNAVAILABLE](https://developer.android.com/reference/android/provider/FontsContract.FontRequestCallback#FAIL_REASON_FONT_UNAVAILABLE) Constant returned by[onTypefaceRequestFailed(int)](https://developer.android.com/reference/android/provider/FontsContract.FontRequestCallback#onTypefaceRequestFailed(int))signaling that the font provider found the queried font, but it is currently unavailable.                          |
| `int` | [FAIL_REASON_MALFORMED_QUERY](https://developer.android.com/reference/android/provider/FontsContract.FontRequestCallback#FAIL_REASON_MALFORMED_QUERY) Constant returned by[onTypefaceRequestFailed(int)](https://developer.android.com/reference/android/provider/FontsContract.FontRequestCallback#onTypefaceRequestFailed(int))signaling that the given query was not supported by the provider.                                                    |
| `int` | [FAIL_REASON_PROVIDER_NOT_FOUND](https://developer.android.com/reference/android/provider/FontsContract.FontRequestCallback#FAIL_REASON_PROVIDER_NOT_FOUND) Constant returned by[onTypefaceRequestFailed(int)](https://developer.android.com/reference/android/provider/FontsContract.FontRequestCallback#onTypefaceRequestFailed(int))signaling that the given provider was not found on the device.                                                 |
| `int` | [FAIL_REASON_WRONG_CERTIFICATES](https://developer.android.com/reference/android/provider/FontsContract.FontRequestCallback#FAIL_REASON_WRONG_CERTIFICATES) Constant returned by[onTypefaceRequestFailed(int)](https://developer.android.com/reference/android/provider/FontsContract.FontRequestCallback#onTypefaceRequestFailed(int))signaling that the given provider must be authenticated and the given certificates do not match its signature. |

|                                                              ### Public constructors                                                               ||
|-------------------------------------------------------------------------------------------------------------------------------------------------|---|
| ` `[FontRequestCallback](https://developer.android.com/reference/android/provider/FontsContract.FontRequestCallback#FontRequestCallback())`() ` |

|                                                                                                                                                                                                                                                                                                                                      ### Public methods                                                                                                                                                                                                                                                                                                                                      ||
|---------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` void` | ` `[onTypefaceRequestFailed](https://developer.android.com/reference/android/provider/FontsContract.FontRequestCallback#onTypefaceRequestFailed(int))`(int reason) ` Called when a Typeface request done via[FontsContract.requestFonts(Context, FontRequest, Handler, CancellationSignal, FontRequestCallback)](https://developer.android.com/reference/android/provider/FontsContract#requestFonts(android.content.Context,%20android.provider.FontRequest,%20android.os.Handler,%20android.os.CancellationSignal,%20android.provider.FontsContract.FontRequestCallback))} fails.                                                                                                 |
| ` void` | ` `[onTypefaceRetrieved](https://developer.android.com/reference/android/provider/FontsContract.FontRequestCallback#onTypefaceRetrieved(android.graphics.Typeface))`(`[Typeface](https://developer.android.com/reference/android/graphics/Typeface)` typeface) ` Called then a Typeface request done via[FontsContract.requestFonts(Context, FontRequest, Handler, CancellationSignal, FontRequestCallback)](https://developer.android.com/reference/android/provider/FontsContract#requestFonts(android.content.Context,%20android.provider.FontRequest,%20android.os.Handler,%20android.os.CancellationSignal,%20android.provider.FontsContract.FontRequestCallback))is complete. |

| ### Inherited methods |
|-----------------------|---|
| From class` `[java.lang.Object](https://developer.android.com/reference/java/lang/Object)` ` |--------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` `[Object](https://developer.android.com/reference/java/lang/Object)          | ` `[clone](https://developer.android.com/reference/java/lang/Object#clone())`() ` Creates and returns a copy of this object.                                                                                                                                                      | | ` boolean`                                                                     | ` `[equals](https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` obj) ` Indicates whether some other object is "equal to" this one.                                           | | ` void`                                                                        | ` `[finalize](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 `[Class](https://developer.android.com/reference/java/lang/Class)`<?>` | ` `[getClass](https://developer.android.com/reference/java/lang/Object#getClass())`() ` Returns the runtime class of this`Object`.                                                                                                                                                | | ` int`                                                                         | ` `[hashCode](https://developer.android.com/reference/java/lang/Object#hashCode())`() ` Returns a hash code value for the object.                                                                                                                                                 | | ` final void`                                                                  | ` `[notify](https://developer.android.com/reference/java/lang/Object#notify())`() ` Wakes up a single thread that is waiting on this object's monitor.                                                                                                                            | | ` final void`                                                                  | ` `[notifyAll](https://developer.android.com/reference/java/lang/Object#notifyAll())`() ` Wakes up all threads that are waiting on this object's monitor.                                                                                                                         | | ` `[String](https://developer.android.com/reference/java/lang/String)          | ` `[toString](https://developer.android.com/reference/java/lang/Object#toString())`() ` Returns a string representation of the object.                                                                                                                                            | | ` final void`                                                                  | ` `[wait](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`                                                                  | ` `[wait](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`                                                                  | ` `[wait](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*.                                                                                             | ||

## Constants

### FAIL_REASON_FONT_LOAD_ERROR

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

```
public static final int FAIL_REASON_FONT_LOAD_ERROR
```

Constant returned by[onTypefaceRequestFailed(int)](https://developer.android.com/reference/android/provider/FontsContract.FontRequestCallback#onTypefaceRequestFailed(int))signaling that the font returned by the provider was not loaded properly.

<br />

Constant Value: -3 (0xfffffffd)  

### FAIL_REASON_FONT_NOT_FOUND

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

```
public static final int FAIL_REASON_FONT_NOT_FOUND
```

Constant returned by[onTypefaceRequestFailed(int)](https://developer.android.com/reference/android/provider/FontsContract.FontRequestCallback#onTypefaceRequestFailed(int))signaling that the font provider did not return any results for the given query.

<br />

Constant Value: 1 (0x00000001)  

### FAIL_REASON_FONT_UNAVAILABLE

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

```
public static final int FAIL_REASON_FONT_UNAVAILABLE
```

Constant returned by[onTypefaceRequestFailed(int)](https://developer.android.com/reference/android/provider/FontsContract.FontRequestCallback#onTypefaceRequestFailed(int))signaling that the font provider found the queried font, but it is currently unavailable.

<br />

Constant Value: 2 (0x00000002)  

### FAIL_REASON_MALFORMED_QUERY

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

```
public static final int FAIL_REASON_MALFORMED_QUERY
```

Constant returned by[onTypefaceRequestFailed(int)](https://developer.android.com/reference/android/provider/FontsContract.FontRequestCallback#onTypefaceRequestFailed(int))signaling that the given query was not supported by the provider.

<br />

Constant Value: 3 (0x00000003)  

### FAIL_REASON_PROVIDER_NOT_FOUND

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

```
public static final int FAIL_REASON_PROVIDER_NOT_FOUND
```

Constant returned by[onTypefaceRequestFailed(int)](https://developer.android.com/reference/android/provider/FontsContract.FontRequestCallback#onTypefaceRequestFailed(int))signaling that the given provider was not found on the device.

<br />

Constant Value: -1 (0xffffffff)  

### FAIL_REASON_WRONG_CERTIFICATES

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

```
public static final int FAIL_REASON_WRONG_CERTIFICATES
```

Constant returned by[onTypefaceRequestFailed(int)](https://developer.android.com/reference/android/provider/FontsContract.FontRequestCallback#onTypefaceRequestFailed(int))signaling that the given provider must be authenticated and the given certificates do not match its signature.

<br />

Constant Value: -2 (0xfffffffe)

## Public constructors

### FontRequestCallback

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

```
public FontRequestCallback ()
```

<br />

<br />

## Public methods

### onTypefaceRequestFailed

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

```
public void onTypefaceRequestFailed (int reason)
```

Called when a Typeface request done via[FontsContract.requestFonts(Context, FontRequest, Handler, CancellationSignal, FontRequestCallback)](https://developer.android.com/reference/android/provider/FontsContract#requestFonts(android.content.Context,%20android.provider.FontRequest,%20android.os.Handler,%20android.os.CancellationSignal,%20android.provider.FontsContract.FontRequestCallback))} fails.

<br />

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   Parameters                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   ||
|----------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `reason` | `int`: One of[FAIL_REASON_PROVIDER_NOT_FOUND](https://developer.android.com/reference/android/provider/FontsContract.FontRequestCallback#FAIL_REASON_PROVIDER_NOT_FOUND),[FAIL_REASON_FONT_NOT_FOUND](https://developer.android.com/reference/android/provider/FontsContract.FontRequestCallback#FAIL_REASON_FONT_NOT_FOUND),[FAIL_REASON_FONT_LOAD_ERROR](https://developer.android.com/reference/android/provider/FontsContract.FontRequestCallback#FAIL_REASON_FONT_LOAD_ERROR),[FAIL_REASON_FONT_UNAVAILABLE](https://developer.android.com/reference/android/provider/FontsContract.FontRequestCallback#FAIL_REASON_FONT_UNAVAILABLE)or[FAIL_REASON_MALFORMED_QUERY](https://developer.android.com/reference/android/provider/FontsContract.FontRequestCallback#FAIL_REASON_MALFORMED_QUERY)if returned by the system. May also be a positive value greater than 0 defined by the font provider as an additional error code. Refer to the provider's documentation for more information on possible returned error codes. Value is[FAIL_REASON_PROVIDER_NOT_FOUND](https://developer.android.com/reference/android/provider/FontsContract.FontRequestCallback#FAIL_REASON_PROVIDER_NOT_FOUND),[FAIL_REASON_FONT_LOAD_ERROR](https://developer.android.com/reference/android/provider/FontsContract.FontRequestCallback#FAIL_REASON_FONT_LOAD_ERROR),[FAIL_REASON_FONT_NOT_FOUND](https://developer.android.com/reference/android/provider/FontsContract.FontRequestCallback#FAIL_REASON_FONT_NOT_FOUND),[FAIL_REASON_FONT_UNAVAILABLE](https://developer.android.com/reference/android/provider/FontsContract.FontRequestCallback#FAIL_REASON_FONT_UNAVAILABLE), or[FAIL_REASON_MALFORMED_QUERY](https://developer.android.com/reference/android/provider/FontsContract.FontRequestCallback#FAIL_REASON_MALFORMED_QUERY) <br /> |

### onTypefaceRetrieved

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

```
public void onTypefaceRetrieved (Typeface typeface)
```

Called then a Typeface request done via[FontsContract.requestFonts(Context, FontRequest, Handler, CancellationSignal, FontRequestCallback)](https://developer.android.com/reference/android/provider/FontsContract#requestFonts(android.content.Context,%20android.provider.FontRequest,%20android.os.Handler,%20android.os.CancellationSignal,%20android.provider.FontsContract.FontRequestCallback))is complete. Note that this method will not be called if[onTypefaceRequestFailed(int)](https://developer.android.com/reference/android/provider/FontsContract.FontRequestCallback#onTypefaceRequestFailed(int))is called instead.

<br />

|                          Parameters                           ||
|------------|---------------------------------------------------|
| `typeface` | `Typeface`: The Typeface object retrieved. <br /> |