public static class ShortcutInfo.Builder extends Object
ShortcutInfo
objects.ShortcutManager
Constructor and Description |
---|
Builder(Context context)
Deprecated.
|
Builder(Context context,
String id)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
ShortcutInfo |
build()
Creates a
ShortcutInfo instance. |
ShortcutInfo.Builder |
setActivity(ComponentName activity)
Sets the target activity.
|
ShortcutInfo.Builder |
setCategories(Set<String> categories)
Sets categories for a shortcut.
|
ShortcutInfo.Builder |
setDisabledMessage(CharSequence disabledMessage)
Sets the message that should be shown when the user attempts to start a shortcut that
is disabled.
|
ShortcutInfo.Builder |
setDisabledMessageResId(int disabledMessageResId)
Deprecated.
|
ShortcutInfo.Builder |
setExtras(PersistableBundle extras)
Extras that the app can set for any purpose.
|
ShortcutInfo.Builder |
setIcon(Icon icon)
Sets an icon of a shortcut.
|
ShortcutInfo.Builder |
setId(String id)
Deprecated.
|
ShortcutInfo.Builder |
setIntent(Intent intent)
Sets the intent of a shortcut.
|
ShortcutInfo.Builder |
setIntents(Intent[] intents)
Sets multiple intents instead of a single intent, in order to launch an activity with
other activities in back stack.
|
ShortcutInfo.Builder |
setLongLabel(CharSequence longLabel)
Sets the text of a shortcut.
|
ShortcutInfo.Builder |
setLongLabelResId(int longLabelResId)
Deprecated.
|
ShortcutInfo.Builder |
setRank(int rank)
"Rank" of a shortcut, which is a non-negative value that's used by the launcher app
to sort shortcuts.
|
ShortcutInfo.Builder |
setShortLabel(CharSequence shortLabel)
Sets the short title of a shortcut.
|
ShortcutInfo.Builder |
setShortLabelResId(int shortLabelResId)
Deprecated.
|
ShortcutInfo.Builder |
setText(CharSequence value)
Deprecated.
|
ShortcutInfo.Builder |
setTextResId(int value)
Deprecated.
|
ShortcutInfo.Builder |
setTitle(CharSequence value)
Deprecated.
|
ShortcutInfo.Builder |
setTitleResId(int value)
Deprecated.
|
@Deprecated public Builder(Context context)
@Deprecated public ShortcutInfo.Builder setId(String id)
public ShortcutInfo.Builder setActivity(ComponentName activity)
ShortcutManager.addDynamicShortcuts(List)
or
ShortcutManager.setDynamicShortcuts(List)
,
the first main activity defined in the app's AndroidManifest.xml
file is used.
Intent.ACTION_MAIN
and Intent.CATEGORY_LAUNCHER
intent filters—can be target
activities.
ShortcutInfo.getActivity()
public ShortcutInfo.Builder setIcon(Icon icon)
Icons are not available on ShortcutInfo
instances
returned by ShortcutManager
or LauncherApps
. The default launcher
app can use LauncherApps.getShortcutIconDrawable(ShortcutInfo, int)
or LauncherApps.getShortcutBadgedIconDrawable(ShortcutInfo, int)
to fetch
shortcut icons.
Tints set with Icon.setTint(int)
or Icon.setTintList(android.content.res.ColorStateList)
are not supported
and will be ignored.
Only icons created with Icon.createWithBitmap(Bitmap)
and
Icon.createWithResource(android.content.Context, int)
are supported.
Other types, such as URI-based icons, are not supported.
@Deprecated public ShortcutInfo.Builder setShortLabelResId(int shortLabelResId)
public ShortcutInfo.Builder setShortLabel(CharSequence shortLabel)
This is a mandatory field when publishing a new shortcut with
ShortcutManager.addDynamicShortcuts(List)
or
ShortcutManager.setDynamicShortcuts(List)
.
This field is intended to be a concise description of a shortcut.
The recommended maximum length is 10 characters.
ShortcutInfo.getShortLabel()
@Deprecated public ShortcutInfo.Builder setLongLabelResId(int longLabelResId)
public ShortcutInfo.Builder setLongLabel(CharSequence longLabel)
This field is intended to be more descriptive than the shortcut title. The launcher shows this instead of the short title when it has enough space.
The recommend maximum length is 25 characters.
ShortcutInfo.getLongLabel()
@Deprecated public ShortcutInfo.Builder setTitle(CharSequence value)
@Deprecated public ShortcutInfo.Builder setTitleResId(int value)
@Deprecated public ShortcutInfo.Builder setText(CharSequence value)
@Deprecated public ShortcutInfo.Builder setTextResId(int value)
@Deprecated public ShortcutInfo.Builder setDisabledMessageResId(int disabledMessageResId)
public ShortcutInfo.Builder setDisabledMessage(CharSequence disabledMessage)
ShortcutInfo.getDisabledMessage()
public ShortcutInfo.Builder setCategories(Set<String> categories)
public ShortcutInfo.Builder setIntent(Intent intent)
setIntents(Intent[])
can be used
to launch an activity with other activities in the back stack.
This is a mandatory field when publishing a new shortcut with
ShortcutManager.addDynamicShortcuts(List)
or
ShortcutManager.setDynamicShortcuts(List)
.
A shortcut can launch any intent that the publisher app has permission to launch. For example, a shortcut can launch an unexported activity within the publisher app. A shortcut intent doesn't have to point at the target activity.
The given intent
can contain extras, but these extras must contain values
of primitive types in order for the system to persist these values.
ShortcutInfo.getIntent()
,
setIntents(Intent[])
public ShortcutInfo.Builder setIntents(Intent[] intents)
TaskStackBuilder
to build intents. The
last element in the list represents the only intent that doesn't place an activity on
the back stack.
See the ShortcutManager
javadoc for details.public ShortcutInfo.Builder setRank(int rank)
ShortcutInfo.getRank()
for details.public ShortcutInfo.Builder setExtras(PersistableBundle extras)
Apps can store arbitrary shortcut metadata in extras and retrieve the
metadata later using ShortcutInfo.getExtras()
.
public ShortcutInfo build()
ShortcutInfo
instance.