LauncherApps.PinItemRequest

public static final class LauncherApps.PinItemRequest
extends Object implements Parcelable

java.lang.Object
   ↳ android.content.pm.LauncherApps.PinItemRequest


Represents a "pin shortcut" or a "pin appwidget" request made by an app, which is sent with an LauncherApps.ACTION_CONFIRM_PIN_SHORTCUT or LauncherApps.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 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

int REQUEST_TYPE_APPWIDGET

This is a request to pin app widget.

int REQUEST_TYPE_SHORTCUT

This is a request to pin shortcut.

Inherited constants

Fields

public static final Creator<LauncherApps.PinItemRequest> CREATOR

Public methods

boolean accept(Bundle options)

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

boolean accept()

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

int describeContents()

Describe the kinds of special objects contained in this Parcelable instance's marshaled representation.

AppWidgetProviderInfo getAppWidgetProviderInfo(Context context)

AppWidgetProviderInfo sent by the requesting app.

Bundle getExtras()

Any extras sent by the requesting app.

int getRequestType()

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

ShortcutInfo getShortcutInfo()

ShortcutInfo sent by the requesting app.

boolean isValid()

Return whether a request is still valid.

void writeToParcel(Parcel dest, int flags)

Flatten this object in to a Parcel.

Inherited methods

Constants

REQUEST_TYPE_APPWIDGET

Added in API level 26
public static final int REQUEST_TYPE_APPWIDGET

This is a request to pin app widget.

Constant Value: 2 (0x00000002)

REQUEST_TYPE_SHORTCUT

Added in API level 26
public static final int REQUEST_TYPE_SHORTCUT

This is a request to pin shortcut.

Constant Value: 1 (0x00000001)

Fields

CREATOR

Added in API level 26
public static final Creator<LauncherApps.PinItemRequest> CREATOR

Public methods

accept

Added in API level 26
public boolean accept (Bundle options)

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.

Returns
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
public boolean accept ()

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

Returns
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
public int describeContents ()

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 writeToParcel(android.os.Parcel, int), the return value of this method must include the CONTENTS_FILE_DESCRIPTOR bit.

Returns
int a bitmask indicating the set of special object types marshaled by this Parcelable object instance. Value is either 0 or CONTENTS_FILE_DESCRIPTOR

getAppWidgetProviderInfo

Added in API level 26
public AppWidgetProviderInfo getAppWidgetProviderInfo (Context context)

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).

Parameters
context Context

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

getExtras

Added in API level 26
public Bundle getExtras ()

Any extras sent by the requesting app.

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

getRequestType

Added in API level 26
public int getRequestType ()

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

Returns
int one of the REQUEST_TYPE_ constants. Value is REQUEST_TYPE_SHORTCUT, or REQUEST_TYPE_APPWIDGET

getShortcutInfo

Added in API level 26
public ShortcutInfo getShortcutInfo ()

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

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

isValid

Added in API level 26
public boolean isValid ()

Return whether a request is still valid.

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

writeToParcel

Added in API level 26
public void writeToParcel (Parcel dest, 
                int flags)

Flatten this object in to a Parcel.

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.PARCELABLE_WRITE_RETURN_VALUE. Value is either 0 or a combination of Parcelable.PARCELABLE_WRITE_RETURN_VALUE, and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES