Added in API level 26

PinItemRequest


class PinItemRequest : Parcelable
kotlin.Any
   ↳ android.content.pm.LauncherApps.PinItemRequest

Represents a "pin shortcut" or a "pin appwidget" request made by an app, which is sent with an ACTION_CONFIRM_PIN_SHORTCUT or ACTION_CONFIRM_PIN_APPWIDGET intent respectively to the default launcher app.

Request of the REQUEST_TYPE_SHORTCUT type.

A REQUEST_TYPE_SHORTCUT request represents a request to pin a ShortcutInfo. If the launcher accepts a request, call accept(), or accept(android.os.Bundle) with a null or empty Bundle. No options are defined for pin-shortcuts requests.

getShortcutInfo() always returns a non-null ShortcutInfo for this type.

The launcher may receive a request with a ShortcutInfo that is already pinned, in which case 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, accept() must still be called even though the shortcut is already pinned, and create a new pinned shortcut icon for it.

See also ShortcutManager for more details.

Request of the REQUEST_TYPE_APPWIDGET type.

A REQUEST_TYPE_SHORTCUT request represents a request to pin a an AppWidget. If the launcher accepts a request, call accept(android.os.Bundle) with the appwidget integer ID set to the android.appwidget.AppWidgetManager#EXTRA_APPWIDGET_ID extra.

getAppWidgetProviderInfo(android.content.Context) always returns a non-null AppWidgetProviderInfo for this type.

See also AppWidgetManager for more details.

Summary

Constants
static Int

This is a request to pin app widget.

static Int

This is a request to pin shortcut.

Inherited constants
Public methods
Boolean

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

Boolean
accept(options: Bundle?)

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

Int

AppWidgetProviderInfo?

AppWidgetProviderInfo sent by the requesting app.

Bundle?

Any extras sent by the requesting app.

Int

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

ShortcutInfo?

ShortcutInfo sent by the requesting app.

Boolean

Return whether a request is still valid.

Unit
writeToParcel(dest: Parcel, flags: Int)

Properties
static Parcelable.Creator<LauncherApps.PinItemRequest!>

Constants

REQUEST_TYPE_APPWIDGET

Added in API level 26
static val REQUEST_TYPE_APPWIDGET: Int

This is a request to pin app widget.

Value: 2

REQUEST_TYPE_SHORTCUT

Added in API level 26
static val REQUEST_TYPE_SHORTCUT: Int

This is a request to pin shortcut.

Value: 1

Public methods

accept

Added in API level 26
fun accept(): Boolean

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

Return
Boolean 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
fun accept(options: Bundle?): Boolean

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

Parameters
options Bundle?: must be set for a REQUEST_TYPE_APPWIDGET request. This value may be null.
Return
Boolean 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
fun describeContents(): Int
Return
Int a bitmask indicating the set of special object types marshaled by this Parcelable object instance. Value is either 0 or android.os.Parcelable#CONTENTS_FILE_DESCRIPTOR

getAppWidgetProviderInfo

Added in API level 26
fun getAppWidgetProviderInfo(context: Context!): AppWidgetProviderInfo?

AppWidgetProviderInfo sent by the requesting app. Always non-null for a REQUEST_TYPE_APPWIDGET 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 accept(android.os.Bundle).

Return
AppWidgetProviderInfo? requested AppWidgetProviderInfo when a request is of the REQUEST_TYPE_APPWIDGET type. Null otherwise.

getExtras

Added in API level 26
fun getExtras(): Bundle?

Any extras sent by the requesting app.

Return
Bundle? For a shortcut request, this method always return null. For an AppWidget request, this method returns the extras passed to the android.appwidget.AppWidgetManager#requestPinAppWidget( * ComponentName, Bundle, PendingIntent) API. See AppWidgetManager for details.

getRequestType

Added in API level 26
fun getRequestType(): Int

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

Return
Int one of the REQUEST_TYPE_ constants. Value is android.content.pm.LauncherApps.PinItemRequest#REQUEST_TYPE_SHORTCUT, or android.content.pm.LauncherApps.PinItemRequest#REQUEST_TYPE_APPWIDGET

getShortcutInfo

Added in API level 26
fun getShortcutInfo(): ShortcutInfo?

ShortcutInfo sent by the requesting app. Always non-null for a REQUEST_TYPE_SHORTCUT request, and always null for a different request type.

Return
ShortcutInfo? requested ShortcutInfo when a request is of the REQUEST_TYPE_SHORTCUT type. Null otherwise.

isValid

Added in API level 26
fun isValid(): Boolean

Return whether a request is still valid.

Return
Boolean TRUE if a request is valid and accept(android.os.Bundle) may be called.

writeToParcel

Added in API level 26
fun writeToParcel(
    dest: Parcel,
    flags: Int
): Unit
Parameters
dest Parcel: The Parcel in which the object should be written. This value cannot be null.
flags Int: Additional flags about how the object should be written. May be 0 or PARCELABLE_WRITE_RETURN_VALUE. Value is either 0 or a combination of android.os.Parcelable#PARCELABLE_WRITE_RETURN_VALUE, and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES

Properties

CREATOR

Added in API level 26
static val CREATOR: Parcelable.Creator<LauncherApps.PinItemRequest!>