Skip to content

Most visited

Recently visited

navigation

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 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(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 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(Bundle) with the appwidget integer ID set to the EXTRA_APPWIDGET_ID extra.

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

See also AppWidgetManager for more details.

See also:

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

From interface android.os.Parcelable

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

From class java.lang.Object
From interface android.os.Parcelable

Constants

REQUEST_TYPE_APPWIDGET

int REQUEST_TYPE_APPWIDGET

This is a request to pin app widget.

Constant Value: 2 (0x00000002)

REQUEST_TYPE_SHORTCUT

int REQUEST_TYPE_SHORTCUT

This is a request to pin shortcut.

Constant Value: 1 (0x00000001)

Fields

Public methods

accept

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

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

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

getAppWidgetProviderInfo

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.

Parameters
context Context

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

This value may be null.

getExtras

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 requestPinAppWidget(ComponentName, Bundle, PendingIntent) API. See AppWidgetManager for details.

This value may be null.

getRequestType

int getRequestType ()

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

Returns
int one of the REQUEST_TYPE_ constants.

getShortcutInfo

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.

This value may be null.

isValid

boolean isValid ()

Return whether a request is still valid.

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

writeToParcel

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.

flags int: Additional flags about how the object should be written. May be 0 or PARCELABLE_WRITE_RETURN_VALUE.

This site uses cookies to store your preferences for site-specific language and display options.

Get the latest Android developer news and tips that will help you find success on Google Play.

* Required Fields

Hooray!

Browse this site in ?

You requested a page in , but your language preference for this site is .

Would you like to change your language preference and browse this site in ? If you want to change your language preference later, use the language menu at the bottom of each page.

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a one-minute survey?
Help us improve Android tools and documentation.