# LauncherApps.ShortcutQuery

Added in [API level 25](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Summary: [Constants](https://developer.android.com/reference/android/content/pm/LauncherApps.ShortcutQuery#constants) \| [Ctors](https://developer.android.com/reference/android/content/pm/LauncherApps.ShortcutQuery#pubctors) \| [Methods](https://developer.android.com/reference/android/content/pm/LauncherApps.ShortcutQuery#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/content/pm/LauncherApps.ShortcutQuery#inhmethods)  

# LauncherApps.ShortcutQuery

*** ** * ** ***

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


`
public
static


class
LauncherApps.ShortcutQuery
`


`

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


`

`


`

|---|-----------------------------------------------|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.content.pm.LauncherApps.ShortcutQuery |

<br />

*** ** * ** ***

Represents a query passed to [LauncherApps.getShortcuts(android.content.pm.LauncherApps.ShortcutQuery, android.os.UserHandle)](https://developer.android.com/reference/android/content/pm/LauncherApps#getShortcuts(android.content.pm.LauncherApps.ShortcutQuery,%20android.os.UserHandle)).

## Summary

|                                                                                                                       ### Constants                                                                                                                       ||
|-------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `int` | [FLAG_GET_KEY_FIELDS_ONLY](https://developer.android.com/reference/android/content/pm/LauncherApps.ShortcutQuery#FLAG_GET_KEY_FIELDS_ONLY) Requests "key" fields only.                                                                             |
| `int` | [FLAG_MATCH_CACHED](https://developer.android.com/reference/android/content/pm/LauncherApps.ShortcutQuery#FLAG_MATCH_CACHED) Include cached shortcuts in the result.                                                                               |
| `int` | [FLAG_MATCH_DYNAMIC](https://developer.android.com/reference/android/content/pm/LauncherApps.ShortcutQuery#FLAG_MATCH_DYNAMIC) Include dynamic shortcuts in the result.                                                                            |
| `int` | [FLAG_MATCH_MANIFEST](https://developer.android.com/reference/android/content/pm/LauncherApps.ShortcutQuery#FLAG_MATCH_MANIFEST) Include manifest shortcuts in the result.                                                                         |
| `int` | [FLAG_MATCH_PINNED](https://developer.android.com/reference/android/content/pm/LauncherApps.ShortcutQuery#FLAG_MATCH_PINNED) Include pinned shortcuts in the result.                                                                               |
| `int` | [FLAG_MATCH_PINNED_BY_ANY_LAUNCHER](https://developer.android.com/reference/android/content/pm/LauncherApps.ShortcutQuery#FLAG_MATCH_PINNED_BY_ANY_LAUNCHER) Include all pinned shortcuts by any launchers, not just by the caller, in the result. |

|                                                      ### Public constructors                                                      ||
|--------------------------------------------------------------------------------------------------------------------------------|---|
| ` `[ShortcutQuery](https://developer.android.com/reference/android/content/pm/LauncherApps.ShortcutQuery#ShortcutQuery())`() ` |

|                                                                                                                                                                                                                                                             ### Public methods                                                                                                                                                                                                                                                             ||
|------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` `[LauncherApps.ShortcutQuery](https://developer.android.com/reference/android/content/pm/LauncherApps.ShortcutQuery) | ` `[setActivity](https://developer.android.com/reference/android/content/pm/LauncherApps.ShortcutQuery#setActivity(android.content.ComponentName))`(`[ComponentName](https://developer.android.com/reference/android/content/ComponentName)` activity) ` If non-null, returns only shortcuts associated with the activity; i.e.                                                                                    |
| ` `[LauncherApps.ShortcutQuery](https://developer.android.com/reference/android/content/pm/LauncherApps.ShortcutQuery) | ` `[setChangedSince](https://developer.android.com/reference/android/content/pm/LauncherApps.ShortcutQuery#setChangedSince(long))`(long changedSince) ` If non-zero, returns only shortcuts that have been added or updated since the given timestamp, expressed in milliseconds since the Epoch---see [System.currentTimeMillis()](https://developer.android.com/reference/java/lang/System#currentTimeMillis()). |
| ` `[LauncherApps.ShortcutQuery](https://developer.android.com/reference/android/content/pm/LauncherApps.ShortcutQuery) | ` `[setLocusIds](https://developer.android.com/reference/android/content/pm/LauncherApps.ShortcutQuery#setLocusIds(java.util.List<android.content.LocusId>))`(`[List](https://developer.android.com/reference/java/util/List)`<`[LocusId](https://developer.android.com/reference/android/content/LocusId)`> locusIds) ` If non-null, return only the specified shortcuts by locus ID.                             |
| ` `[LauncherApps.ShortcutQuery](https://developer.android.com/reference/android/content/pm/LauncherApps.ShortcutQuery) | ` `[setPackage](https://developer.android.com/reference/android/content/pm/LauncherApps.ShortcutQuery#setPackage(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` packageName) ` If non-null, returns only shortcuts from the package.                                                                                                                                     |
| ` `[LauncherApps.ShortcutQuery](https://developer.android.com/reference/android/content/pm/LauncherApps.ShortcutQuery) | ` `[setQueryFlags](https://developer.android.com/reference/android/content/pm/LauncherApps.ShortcutQuery#setQueryFlags(int))`(int queryFlags) ` Set query options.                                                                                                                                                                                                                                                 |
| ` `[LauncherApps.ShortcutQuery](https://developer.android.com/reference/android/content/pm/LauncherApps.ShortcutQuery) | ` `[setShortcutIds](https://developer.android.com/reference/android/content/pm/LauncherApps.ShortcutQuery#setShortcutIds(java.util.List<java.lang.String>))`(`[List](https://developer.android.com/reference/java/util/List)`<`[String](https://developer.android.com/reference/java/lang/String)`> shortcutIds) ` If non-null, return only the specified shortcuts by ID.                                         |

| ### 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

### FLAG_GET_KEY_FIELDS_ONLY

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

```
public static final int FLAG_GET_KEY_FIELDS_ONLY
```

Requests "key" fields only. See [ShortcutInfo.hasKeyFieldsOnly()](https://developer.android.com/reference/android/content/pm/ShortcutInfo#hasKeyFieldsOnly())'s javadoc to
see which fields fields "key".
This allows quicker access to shortcut information in order to
determine whether the caller's in-memory cache needs to be updated.

Typically, launcher applications cache all or most shortcut information
in memory in order to show shortcuts without a delay.

When a given launcher application wants to update its cache, such as when its process
restarts, it can fetch shortcut information with this flag.
The application can then check [ShortcutInfo.getLastChangedTimestamp()](https://developer.android.com/reference/android/content/pm/ShortcutInfo#getLastChangedTimestamp()) for each
shortcut, fetching a shortcut's non-key information only if that shortcut has been
updated.

<br />

**See also:**

- [ShortcutManager](https://developer.android.com/reference/android/content/pm/ShortcutManager)

Constant Value:

4
(0x00000004)


### FLAG_MATCH_CACHED

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

```
public static final int FLAG_MATCH_CACHED
```

Include cached shortcuts in the result.

<br />

Constant Value:

16
(0x00000010)


### FLAG_MATCH_DYNAMIC

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

```
public static final int FLAG_MATCH_DYNAMIC
```

Include dynamic shortcuts in the result.

<br />

Constant Value:

1
(0x00000001)


### FLAG_MATCH_MANIFEST

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

```
public static final int FLAG_MATCH_MANIFEST
```

Include manifest shortcuts in the result.

<br />

Constant Value:

8
(0x00000008)


### FLAG_MATCH_PINNED

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

```
public static final int FLAG_MATCH_PINNED
```

Include pinned shortcuts in the result.

If you are the selected assistant app, and wishes to fetch all shortcuts that the
user owns on the launcher (or by other launchers, in case the user has multiple), use
[FLAG_MATCH_PINNED_BY_ANY_LAUNCHER](https://developer.android.com/reference/android/content/pm/LauncherApps.ShortcutQuery#FLAG_MATCH_PINNED_BY_ANY_LAUNCHER) instead.

If you're a regular launcher app, there's no way to get shortcuts pinned by other
launchers, and [FLAG_MATCH_PINNED_BY_ANY_LAUNCHER](https://developer.android.com/reference/android/content/pm/LauncherApps.ShortcutQuery#FLAG_MATCH_PINNED_BY_ANY_LAUNCHER) will be ignored. So use this
flag to get own pinned shortcuts.

<br />

Constant Value:

2
(0x00000002)


### FLAG_MATCH_PINNED_BY_ANY_LAUNCHER

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

```
public static final int FLAG_MATCH_PINNED_BY_ANY_LAUNCHER
```

Include all pinned shortcuts by any launchers, not just by the caller,
in the result.

The caller must be the selected assistant app to use this flag, or have the system
`ACCESS_SHORTCUTS` permission.

If you are the selected assistant app, and wishes to fetch all shortcuts that the
user owns on the launcher (or by other launchers, in case the user has multiple), use
[FLAG_MATCH_PINNED_BY_ANY_LAUNCHER](https://developer.android.com/reference/android/content/pm/LauncherApps.ShortcutQuery#FLAG_MATCH_PINNED_BY_ANY_LAUNCHER) instead.

If you're a regular launcher app (or any app that's not the selected assistant app)
then this flag will be ignored.

<br />

Constant Value:

1024
(0x00000400)


## Public constructors

### ShortcutQuery

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

```
public ShortcutQuery ()
```

<br />

<br />

## Public methods

### setActivity

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

```
public LauncherApps.ShortcutQuery setActivity (ComponentName activity)
```

If non-null, returns only shortcuts associated with the activity; i.e.
[ShortcutInfo](https://developer.android.com/reference/android/content/pm/ShortcutInfo)s whose [ShortcutInfo.getActivity()](https://developer.android.com/reference/android/content/pm/ShortcutInfo#getActivity()) are equal
to `activity`.

<br />

|                          Parameters                           ||
|------------|---------------------------------------------------|
| `activity` | `ComponentName`: This value may be `null`. <br /> |

|                                                           Returns                                                           ||
|---------------------------------------------------------------------------------------------------------------------|--------|
| [LauncherApps.ShortcutQuery](https://developer.android.com/reference/android/content/pm/LauncherApps.ShortcutQuery) | <br /> |

### setChangedSince

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

```
public LauncherApps.ShortcutQuery setChangedSince (long changedSince)
```

If non-zero, returns only shortcuts that have been added or updated
since the given timestamp, expressed in milliseconds since the Epoch---see
[System.currentTimeMillis()](https://developer.android.com/reference/java/lang/System#currentTimeMillis()).

<br />

|          Parameters           ||
|----------------|---------------|
| `changedSince` | `long` <br /> |

|                                                           Returns                                                           ||
|---------------------------------------------------------------------------------------------------------------------|--------|
| [LauncherApps.ShortcutQuery](https://developer.android.com/reference/android/content/pm/LauncherApps.ShortcutQuery) | <br /> |

### setLocusIds

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

```
public LauncherApps.ShortcutQuery setLocusIds (List<LocusId> locusIds)
```

If non-null, return only the specified shortcuts by locus ID. When setting this field,
a package name must also be set with [setPackage(String)](https://developer.android.com/reference/android/content/pm/LauncherApps.ShortcutQuery#setPackage(java.lang.String)).

<br />

|                      Parameters                      ||
|------------|------------------------------------------|
| `locusIds` | `List`: This value may be `null`. <br /> |

|                                                           Returns                                                           ||
|---------------------------------------------------------------------------------------------------------------------|--------|
| [LauncherApps.ShortcutQuery](https://developer.android.com/reference/android/content/pm/LauncherApps.ShortcutQuery) | <br /> |

### setPackage

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

```
public LauncherApps.ShortcutQuery setPackage (String packageName)
```

If non-null, returns only shortcuts from the package.

<br />

|                        Parameters                         ||
|---------------|--------------------------------------------|
| `packageName` | `String`: This value may be `null`. <br /> |

|                                                           Returns                                                           ||
|---------------------------------------------------------------------------------------------------------------------|--------|
| [LauncherApps.ShortcutQuery](https://developer.android.com/reference/android/content/pm/LauncherApps.ShortcutQuery) | <br /> |

### setQueryFlags

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

```
public LauncherApps.ShortcutQuery setQueryFlags (int queryFlags)
```

Set query options. At least one of the `MATCH` flags should be set. Otherwise,
no shortcuts will be returned.

- [FLAG_MATCH_DYNAMIC](https://developer.android.com/reference/android/content/pm/LauncherApps.ShortcutQuery#FLAG_MATCH_DYNAMIC)
- [FLAG_MATCH_PINNED](https://developer.android.com/reference/android/content/pm/LauncherApps.ShortcutQuery#FLAG_MATCH_PINNED)
- [FLAG_MATCH_MANIFEST](https://developer.android.com/reference/android/content/pm/LauncherApps.ShortcutQuery#FLAG_MATCH_MANIFEST)
- [FLAG_MATCH_CACHED](https://developer.android.com/reference/android/content/pm/LauncherApps.ShortcutQuery#FLAG_MATCH_CACHED)
- [FLAG_GET_KEY_FIELDS_ONLY](https://developer.android.com/reference/android/content/pm/LauncherApps.ShortcutQuery#FLAG_GET_KEY_FIELDS_ONLY)

<br />

<br />

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         Parameters                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         ||
|--------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `queryFlags` | `int`: Value is either `0` or a combination of [FLAG_MATCH_DYNAMIC](https://developer.android.com/reference/android/content/pm/LauncherApps.ShortcutQuery#FLAG_MATCH_DYNAMIC), [FLAG_MATCH_PINNED](https://developer.android.com/reference/android/content/pm/LauncherApps.ShortcutQuery#FLAG_MATCH_PINNED), [FLAG_MATCH_MANIFEST](https://developer.android.com/reference/android/content/pm/LauncherApps.ShortcutQuery#FLAG_MATCH_MANIFEST), [FLAG_MATCH_CACHED](https://developer.android.com/reference/android/content/pm/LauncherApps.ShortcutQuery#FLAG_MATCH_CACHED), [FLAG_MATCH_PINNED_BY_ANY_LAUNCHER](https://developer.android.com/reference/android/content/pm/LauncherApps.ShortcutQuery#FLAG_MATCH_PINNED_BY_ANY_LAUNCHER), [FLAG_GET_KEY_FIELDS_ONLY](https://developer.android.com/reference/android/content/pm/LauncherApps.ShortcutQuery#FLAG_GET_KEY_FIELDS_ONLY), android.content.pm.LauncherApps.ShortcutQuery.FLAG_GET_PERSONS_DATA, and android.content.pm.LauncherApps.ShortcutQuery.FLAG_GET_PERSISTED_DATA <br /> |

|                                                           Returns                                                           ||
|---------------------------------------------------------------------------------------------------------------------|--------|
| [LauncherApps.ShortcutQuery](https://developer.android.com/reference/android/content/pm/LauncherApps.ShortcutQuery) | <br /> |

### setShortcutIds

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

```
public LauncherApps.ShortcutQuery setShortcutIds (List<String> shortcutIds)
```

If non-null, return only the specified shortcuts by ID. When setting this field,
a package name must also be set with [setPackage(String)](https://developer.android.com/reference/android/content/pm/LauncherApps.ShortcutQuery#setPackage(java.lang.String)).

<br />

|                       Parameters                        ||
|---------------|------------------------------------------|
| `shortcutIds` | `List`: This value may be `null`. <br /> |

|                                                           Returns                                                           ||
|---------------------------------------------------------------------------------------------------------------------|--------|
| [LauncherApps.ShortcutQuery](https://developer.android.com/reference/android/content/pm/LauncherApps.ShortcutQuery) | <br /> |