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

# PinItemRequest

*** ** * ** ***

Kotlin \|[Java](https://developer.android.com/reference/android/content/pm/LauncherApps.PinItemRequest "View this page in Java")

```
class PinItemRequest : Parcelable
```

|---|---|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) ||
| ↳ | [android.content.pm.LauncherApps.PinItemRequest](https://developer.android.com/reference/kotlin/android/content/pm/LauncherApps.PinItemRequest#) |

Represents a "pin shortcut" or a "pin appwidget" request made by an app, which is sent with an `https://developer.android.com/reference/kotlin/android/content/pm/LauncherApps#ACTION_CONFIRM_PIN_SHORTCUT:kotlin.String` or `https://developer.android.com/reference/kotlin/android/content/pm/LauncherApps#ACTION_CONFIRM_PIN_APPWIDGET:kotlin.String` intent respectively to the default launcher app.

### Request of the `https://developer.android.com/reference/kotlin/android/content/pm/LauncherApps.PinItemRequest#REQUEST_TYPE_SHORTCUT:kotlin.Int` type.

<br />

A `https://developer.android.com/reference/kotlin/android/content/pm/LauncherApps.PinItemRequest#REQUEST_TYPE_SHORTCUT:kotlin.Int` request represents a request to pin a `https://developer.android.com/reference/kotlin/android/content/pm/ShortcutInfo`. If the launcher accepts a request, call `https://developer.android.com/reference/kotlin/android/content/pm/LauncherApps.PinItemRequest#accept()`, or `https://developer.android.com/reference/kotlin/android/content/pm/LauncherApps.PinItemRequest#accept(android.os.Bundle)` with a null or empty Bundle. No options are defined for pin-shortcuts requests.

`https://developer.android.com/reference/kotlin/android/content/pm/LauncherApps.PinItemRequest#getShortcutInfo()` always returns a non-null `https://developer.android.com/reference/kotlin/android/content/pm/ShortcutInfo` for this type.

The launcher may receive a request with a `https://developer.android.com/reference/kotlin/android/content/pm/ShortcutInfo` that is already pinned, in which case `https://developer.android.com/reference/kotlin/android/content/pm/ShortcutInfo#isPinned()` returns true. This means the user wants to create another pinned shortcut for a shortcut that's already pinned. If the launcher accepts it, `https://developer.android.com/reference/kotlin/android/content/pm/LauncherApps.PinItemRequest#accept()` must still be called even though the shortcut is already pinned, and create a new pinned shortcut icon for it.

See also `https://developer.android.com/reference/kotlin/android/content/pm/ShortcutManager` for more details.

### Request of the `https://developer.android.com/reference/kotlin/android/content/pm/LauncherApps.PinItemRequest#REQUEST_TYPE_APPWIDGET:kotlin.Int` type.

A `https://developer.android.com/reference/kotlin/android/content/pm/LauncherApps.PinItemRequest#REQUEST_TYPE_SHORTCUT:kotlin.Int` request represents a request to pin a an AppWidget. If the launcher accepts a request, call `https://developer.android.com/reference/kotlin/android/content/pm/LauncherApps.PinItemRequest#accept(android.os.Bundle)` with the appwidget integer ID set to the `https://developer.android.com/reference/kotlin/android/appwidget/AppWidgetManager.html#EXTRA_APPWIDGET_ID:kotlin.String` extra.

`https://developer.android.com/reference/kotlin/android/content/pm/LauncherApps.PinItemRequest#getAppWidgetProviderInfo(android.content.Context)` always returns a non-null `https://developer.android.com/reference/kotlin/android/appwidget/AppWidgetProviderInfo.html#` for this type.

See also `https://developer.android.com/reference/kotlin/android/appwidget/AppWidgetManager.html#` for more details.

## Summary

| Constants ||
|---|---|
| static [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | `https://developer.android.com/reference/kotlin/android/content/pm/LauncherApps.PinItemRequest#REQUEST_TYPE_APPWIDGET:kotlin.Int` This is a request to pin app widget. |
| static [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | `https://developer.android.com/reference/kotlin/android/content/pm/LauncherApps.PinItemRequest#REQUEST_TYPE_SHORTCUT:kotlin.Int` This is a request to pin shortcut. |

| Inherited constants ||
|---|---|
| From class `https://developer.android.com/reference/kotlin/android/os/Parcelable.html#` |---|---| | `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/android/os/Parcelable.html#CONTENTS_FILE_DESCRIPTOR:kotlin.Int` Descriptor bit used with `https://developer.android.com/reference/kotlin/android/os/Parcelable.html#describeContents()`: indicates that the Parcelable object's flattened representation includes a file descriptor. <br /> | | `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/android/os/Parcelable.html#PARCELABLE_WRITE_RETURN_VALUE:kotlin.Int` Flag for use with `https://developer.android.com/reference/kotlin/android/os/Parcelable.html#writeToParcel(android.os.Parcel,%20kotlin.Int)`: the object being written is a return value, that is the result of a function such as "`Parcelable someFunction()`", "`void someFunction(out Parcelable)`", or "`void someFunction(inout Parcelable)`". Some implementations may want to release resources at this point. <br /> | ||

| Public methods ||
|---|---|
| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | `https://developer.android.com/reference/kotlin/android/content/pm/LauncherApps.PinItemRequest#accept()()` Called by the receiving launcher app when the user accepts the request, with no options. |
| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | `https://developer.android.com/reference/kotlin/android/content/pm/LauncherApps.PinItemRequest#accept(android.os.Bundle)(options: https://developer.android.com/reference/kotlin/android/os/Bundle.html#?)` Called by the receiving launcher app when the user accepts the request. |
| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | `https://developer.android.com/reference/kotlin/android/content/pm/LauncherApps.PinItemRequest#describeContents()()` Describe the kinds of special objects contained in this Parcelable instance's marshaled representation. |
| [AppWidgetProviderInfo](https://developer.android.com/reference/kotlin/android/appwidget/AppWidgetProviderInfo.html#)? | `https://developer.android.com/reference/kotlin/android/content/pm/LauncherApps.PinItemRequest#getAppWidgetProviderInfo(android.content.Context)(context: https://developer.android.com/reference/kotlin/android/content/Context.html#!)` `https://developer.android.com/reference/kotlin/android/appwidget/AppWidgetProviderInfo.html#` sent by the requesting app. |
| [Bundle](https://developer.android.com/reference/kotlin/android/os/Bundle.html#)? | `https://developer.android.com/reference/kotlin/android/content/pm/LauncherApps.PinItemRequest#getExtras()()` Any extras sent by the requesting app. |
| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | `https://developer.android.com/reference/kotlin/android/content/pm/LauncherApps.PinItemRequest#getRequestType()()` Represents the type of a request, which is one of the `REQUEST_TYPE_` constants. |
| [ShortcutInfo](https://developer.android.com/reference/kotlin/android/content/pm/ShortcutInfo)? | `https://developer.android.com/reference/kotlin/android/content/pm/LauncherApps.PinItemRequest#getShortcutInfo()()` `https://developer.android.com/reference/kotlin/android/content/pm/ShortcutInfo` sent by the requesting app. |
| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | `https://developer.android.com/reference/kotlin/android/content/pm/LauncherApps.PinItemRequest#isValid()()` Return whether a request is still valid. |
| [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | `https://developer.android.com/reference/kotlin/android/content/pm/LauncherApps.PinItemRequest#writeToParcel(android.os.Parcel,%20kotlin.Int)(dest: https://developer.android.com/reference/kotlin/android/os/Parcel.html#, flags: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)` Flatten this object in to a Parcel. |

| Properties ||
|---|---|
| static [Parcelable.Creator](https://developer.android.com/reference/kotlin/android/os/Parcelable.Creator.html#)\<[LauncherApps.PinItemRequest](https://developer.android.com/reference/kotlin/android/content/pm/LauncherApps.PinItemRequest#)!\> | `https://developer.android.com/reference/kotlin/android/content/pm/LauncherApps.PinItemRequest#CREATOR:android.os.Parcelable.Creator` <br /> |

## Constants

### REQUEST_TYPE_APPWIDGET

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

```
static val REQUEST_TYPE_APPWIDGET: Int
```

This is a request to pin app widget.

    Value: 2

### REQUEST_TYPE_SHORTCUT

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

```
static val REQUEST_TYPE_SHORTCUT: Int
```

This is a request to pin shortcut.

    Value: 1

## Public methods

### accept

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

```
fun accept(): Boolean
```

Called by the receiving launcher app when the user accepts the request, with no options.

| Return ||
|---|---|
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html` | `TRUE` if the shortcut or the AppWidget has actually been pinned. `FALSE` if the item hasn't been pinned, for example, because the request had already been canceled, in which case the launcher must not pin the requested item. |

### accept

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

```
fun accept(options: Bundle?): Boolean
```

Called by the receiving launcher app when the user accepts the request.

| Parameters ||
|---|---|
| `options` | [Bundle](https://developer.android.com/reference/kotlin/android/os/Bundle.html#)?: must be set for a `https://developer.android.com/reference/kotlin/android/content/pm/LauncherApps.PinItemRequest#REQUEST_TYPE_APPWIDGET:kotlin.Int` request. This value may be `null`. |

| Return ||
|---|---|
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html` | `TRUE` if the shortcut or the AppWidget has actually been pinned. `FALSE` if the item hasn't been pinned, for example, because the request had already been canceled, in which case the launcher must not pin the requested item. |

### describeContents

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

```
fun describeContents(): Int
```

Describe the kinds of special objects contained in this Parcelable instance's marshaled representation. For example, if the object will include a file descriptor in the output of `https://developer.android.com/reference/kotlin/android/os/Parcelable.html#writeToParcel(android.os.Parcel,%20kotlin.Int)`, the return value of this method must include the `https://developer.android.com/reference/kotlin/android/os/Parcelable.html#CONTENTS_FILE_DESCRIPTOR:kotlin.Int` bit.

| Return ||
|---|---|
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html` | a bitmask indicating the set of special object types marshaled by this Parcelable object instance. Value is either `0` or - `https://developer.android.com/reference/kotlin/android/os/Parcelable.html#CONTENTS_FILE_DESCRIPTOR:kotlin.Int` |

### getAppWidgetProviderInfo

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

```
fun getAppWidgetProviderInfo(context: Context!): AppWidgetProviderInfo?
```

`https://developer.android.com/reference/kotlin/android/appwidget/AppWidgetProviderInfo.html#` sent by the requesting app. Always non-null for a `https://developer.android.com/reference/kotlin/android/content/pm/LauncherApps.PinItemRequest#REQUEST_TYPE_APPWIDGET:kotlin.Int` request, and always null for a different request type.

Launcher should not show any configuration activity associated with the provider, and assume that the widget is already fully configured. Upon accepting the widget, it should pass the widgetId in `https://developer.android.com/reference/kotlin/android/content/pm/LauncherApps.PinItemRequest#accept(android.os.Bundle)`.

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/appwidget/AppWidgetProviderInfo.html#?` | requested `https://developer.android.com/reference/kotlin/android/appwidget/AppWidgetProviderInfo.html#` when a request is of the `https://developer.android.com/reference/kotlin/android/content/pm/LauncherApps.PinItemRequest#REQUEST_TYPE_APPWIDGET:kotlin.Int` type. Null otherwise. |

### getExtras

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

```
fun getExtras(): Bundle?
```

Any extras sent by the requesting app.

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/os/Bundle.html#?` | For a shortcut request, this method always return null. For an AppWidget request, this method returns the extras passed to the `https://developer.android.com/reference/kotlin/android/appwidget/AppWidgetManager.html#requestPinAppWidget(android.content.ComponentName,%20android.os.Bundle,%20android.app.PendingIntent)` API. See `https://developer.android.com/reference/kotlin/android/appwidget/AppWidgetManager.html#` for details. |

### getRequestType

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

```
fun getRequestType(): Int
```

Represents the type of a request, which is one of the `REQUEST_TYPE_` constants.

| Return ||
|---|---|
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html` | one of the `REQUEST_TYPE_` constants. Value is one of the following: - `https://developer.android.com/reference/kotlin/android/content/pm/LauncherApps.PinItemRequest#REQUEST_TYPE_SHORTCUT:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/content/pm/LauncherApps.PinItemRequest#REQUEST_TYPE_APPWIDGET:kotlin.Int` |

### getShortcutInfo

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

```
fun getShortcutInfo(): ShortcutInfo?
```

`https://developer.android.com/reference/kotlin/android/content/pm/ShortcutInfo` sent by the requesting app. Always non-null for a `https://developer.android.com/reference/kotlin/android/content/pm/LauncherApps.PinItemRequest#REQUEST_TYPE_SHORTCUT:kotlin.Int` request, and always null for a different request type.

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/content/pm/ShortcutInfo?` | requested `https://developer.android.com/reference/kotlin/android/content/pm/ShortcutInfo` when a request is of the `https://developer.android.com/reference/kotlin/android/content/pm/LauncherApps.PinItemRequest#REQUEST_TYPE_SHORTCUT:kotlin.Int` type. Null otherwise. |

### isValid

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

```
fun isValid(): Boolean
```

Return whether a request is still valid.

| Return ||
|---|---|
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html` | `TRUE` if a request is valid and `https://developer.android.com/reference/kotlin/android/content/pm/LauncherApps.PinItemRequest#accept(android.os.Bundle)` may be called. |

### writeToParcel

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

```
fun writeToParcel(
    dest: Parcel, 
    flags: Int
): Unit
```

Flatten this object in to a Parcel.

| Parameters ||
|---|---|
| `dest` | [Parcel](https://developer.android.com/reference/kotlin/android/os/Parcel.html#): The Parcel in which the object should be written. This value cannot be `null`. |
| `flags` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): Additional flags about how the object should be written. May be 0 or `https://developer.android.com/reference/kotlin/android/os/Parcelable.html#PARCELABLE_WRITE_RETURN_VALUE:kotlin.Int`. Value is either `0` or a combination of the following: - `https://developer.android.com/reference/kotlin/android/os/Parcelable.html#PARCELABLE_WRITE_RETURN_VALUE:kotlin.Int` |

## Properties

### CREATOR

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

```
static val CREATOR: Parcelable.Creator<LauncherApps.PinItemRequest!>
```