diff --git a/core/java/android/content/pm/ShortcutInfo.java b/core/java/android/content/pm/ShortcutInfo.java
index ed0ac53861764..a854b899a82af 100644
--- a/core/java/android/content/pm/ShortcutInfo.java
+++ b/core/java/android/content/pm/ShortcutInfo.java
@@ -46,7 +46,7 @@ import java.util.List;
import java.util.Set;
/**
- * Represents a "launcher shortcut" that can be published via {@link ShortcutManager}.
+ * Represents a shortcut that can be published via {@link ShortcutManager}.
*
* @see ShortcutManager
*/
@@ -776,17 +776,17 @@ public final class ShortcutInfo implements Parcelable {
* activity is published using
* {@link ShortcutManager#addDynamicShortcuts(List)} or
* {@link ShortcutManager#setDynamicShortcuts(List)},
- * the first main activity defined in the application's AndroidManifest.xml
+ * the first main activity defined in the app's AndroidManifest.xml
* file is used.
*
*
Icons are not available on {@link ShortcutInfo} instances * returned by {@link ShortcutManager} or {@link LauncherApps}. The default launcher - * application can use {@link LauncherApps#getShortcutIconDrawable(ShortcutInfo, int)} + * app can use {@link LauncherApps#getShortcutIconDrawable(ShortcutInfo, int)} * or {@link LauncherApps#getShortcutBadgedIconDrawable(ShortcutInfo, int)} to fetch * shortcut icons. * @@ -933,8 +933,8 @@ public final class ShortcutInfo implements Parcelable { } /** - * Sets categories for a shortcut. Launcher applications may use this information to - * categorise shortcuts. + * Sets categories for a shortcut. Launcher apps may use this information to + * categorize shortcuts. * * @see #SHORTCUT_CATEGORY_CONVERSATION * @see ShortcutInfo#getCategories() @@ -953,9 +953,9 @@ public final class ShortcutInfo implements Parcelable { * {@link ShortcutManager#addDynamicShortcuts(List)} or * {@link ShortcutManager#setDynamicShortcuts(List)}. * - *
A shortcut can launch any intent that the publisher application has permission to + *
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 - * application. A shortcut intent doesn't have to point at the target activity. + * app. A shortcut intent doesn't have to point at the target activity. * *
The given {@code intent} can contain extras, but these extras must contain values * of primitive types in order for the system to persist these values. @@ -970,7 +970,9 @@ public final class ShortcutInfo implements Parcelable { /** * Sets multiple intents instead of a single intent, in order to launch an activity with - * other activities in back stack. Use {@link TaskStackBuilder} to build intents. + * other activities in back stack. Use {@link 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 {@link ShortcutManager} javadoc for details. * * @see Builder#setIntent(Intent) @@ -1006,9 +1008,9 @@ public final class ShortcutInfo implements Parcelable { } /** - * Extras that application can set for any purpose. + * Extras that the app can set for any purpose. * - *
Applications can store arbitrary shortcut metadata in extras and retrieve the + *
Apps can store arbitrary shortcut metadata in extras and retrieve the * metadata later using {@link ShortcutInfo#getExtras()}. */ @NonNull @@ -1029,7 +1031,7 @@ public final class ShortcutInfo implements Parcelable { /** * Returns the ID of a shortcut. * - *
Shortcut IDs are unique within each publisher application and must be stable across + *
Shortcut IDs are unique within each publisher app and must be stable across * devices so that shortcuts will still be valid when restored on a different device. * See {@link ShortcutManager} for details. */ @@ -1039,7 +1041,7 @@ public final class ShortcutInfo implements Parcelable { } /** - * Return the package name of the publisher application. + * Return the package name of the publisher app. */ @NonNull public String getPackage() { @@ -1050,7 +1052,7 @@ public final class ShortcutInfo implements Parcelable { * Return the target activity. * *
This has nothing to do with the activity that this shortcut will launch. - * Launcher applications should show the launcher icon for the returned activity alongside + * Launcher apps should show the launcher icon for the returned activity alongside * this shortcut. * * @see Builder#setActivity @@ -1102,7 +1104,7 @@ public final class ShortcutInfo implements Parcelable { } /** - * Return the shorter description of a shortcut. + * Return the short description of a shortcut. * * @see Builder#setShortLabel(CharSequence) */ @@ -1117,7 +1119,7 @@ public final class ShortcutInfo implements Parcelable { } /** - * Return the longer description of a shortcut. + * Return the long description of a shortcut. * * @see Builder#setLongLabel(CharSequence) */ @@ -1161,7 +1163,7 @@ public final class ShortcutInfo implements Parcelable { * Returns the intent that is executed when the user selects this shortcut. * If setIntents() was used, then return the last intent in the array. * - *
Launcher applications cannot see the intent. If a {@link ShortcutInfo} is + *
Launcher apps cannot see the intent. If a {@link ShortcutInfo} is * obtained via {@link LauncherApps}, then this method will always return null. * Launchers can only start a shortcut intent with {@link LauncherApps#startShortcut}. * @@ -1180,7 +1182,7 @@ public final class ShortcutInfo implements Parcelable { /** * Return the intent set with {@link Builder#setIntents(Intent[])}. * - *
Launcher applications cannot see the intents. If a {@link ShortcutInfo} is + *
Launcher apps cannot see the intents. If a {@link ShortcutInfo} is * obtained via {@link LauncherApps}, then this method will always return null. * Launchers can only start a shortcut intent with {@link LauncherApps#startShortcut}. * @@ -1219,15 +1221,15 @@ public final class ShortcutInfo implements Parcelable { /** * "Rank" of a shortcut, which is a non-negative, sequential value that's unique for each - * {@link #getActivity} for each of the two kinds, dynamic shortcuts and manifest shortcuts. + * {@link #getActivity} for each of the two types of shortcuts (static and dynamic). * - *
Because manifest shortcuts and dynamic shortcuts have overlapping ranks, - * when a launcher application shows shortcuts for an activity, it should first show - * the manifest shortcuts followed by the dynamic shortcuts. Within each of those categories, + *
Because static shortcuts and dynamic shortcuts have overlapping ranks, + * when a launcher app shows shortcuts for an activity, it should first show + * the static shortcuts, followed by the dynamic shortcuts. Within each of those categories, * shortcuts should be sorted by rank in ascending order. * - *
"Floating" shortcuts (i.e. shortcuts that are neither dynamic nor manifest) will all - * have rank 0, because there's no sorting for them. + *
Floating shortcuts, or shortcuts that are neither static nor dynamic, will all + * have rank 0, because they aren't sorted. * * See the {@link ShortcutManager}'s class javadoc for details. * @@ -1274,7 +1276,7 @@ public final class ShortcutInfo implements Parcelable { } /** - * Extras that application can set to any purposes. + * Extras that the app can set for any purpose. * * @see Builder#setExtras(PersistableBundle) */ @@ -1339,12 +1341,13 @@ public final class ShortcutInfo implements Parcelable { } /** - * Return whether a shortcut is published from AndroidManifest.xml or not. If {@code true}, - * it's also {@link #isImmutable()}. + * Return whether a shortcut is static; that is, whether a shortcut is + * published from AndroidManifest.xml. If {@code true}, the shortcut is + * also {@link #isImmutable()}. * *
When an app is upgraded and a shortcut is no longer published from AndroidManifest.xml, - * this will be set to {@code false}. If the shortcut is not pinned, then it'll just disappear. - * However, if it's pinned, it will still be alive, and {@link #isEnabled()} will be + * this will be set to {@code false}. If the shortcut is not pinned, then it'll disappear. + * However, if it's pinned, it will still be visible, {@link #isEnabled()} will be * {@code false} and {@link #isImmutable()} will be {@code true}. */ public boolean isDeclaredInManifest() { @@ -1358,7 +1361,7 @@ public final class ShortcutInfo implements Parcelable { } /** - * @return true if pinned but neither dynamic nor manifest. + * @return true if pinned but neither static nor dynamic. * @hide */ public boolean isFloating() { @@ -1374,9 +1377,10 @@ public final class ShortcutInfo implements Parcelable { * Return if a shortcut is immutable, in which case it cannot be modified with any of * {@link ShortcutManager} APIs. * - *
All manifest shortcuts are immutable. When a manifest shortcut is pinned and then - * disabled because the app is upgraded and its AndroidManifest.xml no longer publishes it, - * {@link #isDeclaredInManifest()} returns {@code false}, but it is still immutable. + *
All static shortcuts are immutable. When a static shortcut is pinned and is then + * disabled because it doesn't appear in AndroidManifest.xml for a newer version of the + * app, {@link #isDeclaredInManifest()} returns {@code false}, but the shortcut + * is still immutable. * *
All shortcuts originally published via the {@link ShortcutManager} APIs * are all mutable. @@ -1561,7 +1565,7 @@ public final class ShortcutInfo implements Parcelable { } /** - * Replaces the intent + * Replaces the intent. * * @throws IllegalArgumentException when extra is not compatible with {@link PersistableBundle}. * diff --git a/core/java/android/content/pm/ShortcutManager.java b/core/java/android/content/pm/ShortcutManager.java index 96ad67c6f3aba..a93870ece823a 100644 --- a/core/java/android/content/pm/ShortcutManager.java +++ b/core/java/android/content/pm/ShortcutManager.java @@ -31,87 +31,90 @@ import com.android.internal.annotations.VisibleForTesting; import java.util.List; /** - * The ShortcutManager manages "launcher shortcuts" (or simply "shortcuts"). Shortcuts provide - * users - * with quick access to activities other than an application's main activity in the currently-active + * The ShortcutManager manages an app's shortcuts. Shortcuts provide users + * with quick access to activities other than an app's main activity in the currently-active * launcher. For example, - * an email application may publish the "compose new email" action, which will directly open the + * an email app may publish the "compose new email" action, which will directly open the * compose activity. The {@link ShortcutInfo} class contains information about each of the * shortcuts themselves. * - *
+ * There are two ways to publish shortcuts: static shortcuts and dynamic shortcuts. * *
AndroidManifest.xml file.
- * Manifest shortcuts are published when an application is installed,
- * and the details of these shortcuts change when an application is upgraded with an updated XML
+ * AndroidManifest.xml file.
+ * Static shortcuts are published when an app is installed,
+ * and the details of these shortcuts change when an app is upgraded with an updated XML
* file.
- * Manifest shortcuts are immutable, and their
+ * Static shortcuts are immutable, and their
* definitions, such as icons and labels, cannot be changed dynamically without upgrading the
- * publisher application.
+ * publisher app.
*
- * Only "main" activities—activities that handle the {@code MAIN} action and the + *
Only main activities—activities that handle the {@code MAIN} action and the * {@code LAUNCHER} category—can have shortcuts. - * If an application has multiple main activities, these activities will have different sets + * If an app has multiple main activities, these activities have different sets * of shortcuts. * - *
Dynamic shortcuts and manifest shortcuts are shown in the currently active launcher when - * the user long-presses on an application launcher icon. The actual gesture may be different - * depending on the launcher application. + *
Static shortcuts and dynamic shortcuts are shown in the currently active launcher when + * the user long-presses on an app's launcher icon. + * + *
Note: The actual gesture may be different + * depending on the launcher app. * *
Each launcher icon can have at most {@link #getMaxShortcutCountPerActivity()} number of - * dynamic and manifest shortcuts combined. + * static and dynamic shortcuts combined. * * *
+ * Launcher apps allow users to pin shortcuts so they're easier to access. Both static * and dynamic shortcuts can be pinned. * Pinned shortcuts cannot be removed by publisher - * applications; they're removed only when the user removes them, - * when the publisher application is uninstalled, or when the - * user performs the "clear data" action on the publisher application from the device's Settings - * application. + * apps; they're removed only when the user removes them, + * when the publisher app is uninstalled, or when the + * user performs the clear data action on the publisher app from the device's Settings + * app. * - *
However, the publisher application can disable pinned shortcuts so they cannot be + *
However, the publisher app can disable pinned shortcuts so they cannot be * started. See the following sections for details. * * *
When a dynamic shortcut is pinned, even when the publisher removes it as a dynamic shortcut, - * the pinned shortcut will still be visible and launchable. This allows an application to have + * the pinned shortcut will still be visible and launchable. This allows an app to have * more than {@link #getMaxShortcutCountPerActivity()} number of shortcuts. * *
For example, suppose {@link #getMaxShortcutCountPerActivity()} is 5: - *
If the deprecated shortcut is pinned, then the pinned shortcut will remain on the launcher, * but it will be disabled automatically. - * Note that, in this case, the pinned shortcut is no longer a manifest shortcut, but it's - * still immutable and cannot be updated using the {@link ShortcutManager} APIs. + * Note that, in this case, the pinned shortcut is no longer a static shortcut, but it's + * still immutable. Therefore, it cannot be updated using this class's APIs. * * *
+ * In order to add static shortcuts to your app, first add
* {@code
- * <manifest xmlns:android="http://schemas.android.com/apk/res/android" - * package="com.example.myapplication"> - * <application . . .> - * <activity android:name="Main"> - * <intent-filter> - * <action android:name="android.intent.action.MAIN" /> - * <category android:name="android.intent.category.LAUNCHER" /> - * </intent-filter> - * <meta-data android:name="android.app.shortcuts" android:resource="@xml/shortcuts"/> - * </activity> - * </application> - * </manifest> + *<manifest xmlns:android="http://schemas.android.com/apk/res/android" + * package="com.example.myapplication"> + * <application ... > + * <activity android:name="Main"> + * <intent-filter> + * <action android:name="android.intent.action.MAIN" /> + * <category android:name="android.intent.category.LAUNCHER" /> + * </intent-filter> + * <meta-data android:name="android.app.shortcuts" + * android:resource="@xml/shortcuts" /> + * </activity> + * </application> + *</manifest> ** - * Then, define your application's manifest shortcuts in the
res/xml/shortcuts.xml
+ * Then, define your app's static shortcuts in the res/xml/shortcuts.xml
* file:
* - * <shortcuts xmlns:android="http://schemas.android.com/apk/res/android" > - * <shortcut - * android:shortcutId="compose" - * android:enabled="true" - * android:icon="@drawable/compose_icon" - * android:shortcutShortLabel="@string/compose_shortcut_short_label1" - * android:shortcutLongLabel="@string/compose_shortcut_long_label1" - * android:shortcutDisabledMessage="@string/compose_disabled_message1" - * > - * <intent - * android:action="android.intent.action.VIEW" - * android:targetPackage="com.example.myapplication" - * android:targetClass="com.example.myapplication.ComposeActivity" /> - * <!-- more intents can go here; see below --> - * <categories android:name="android.shortcut.conversation" /> - * </shortcut> - * <!-- more shortcuts can go here --> - * </shortcuts> + *<shortcuts xmlns:android="http://schemas.android.com/apk/res/android"> + * <shortcut + * android:shortcutId="compose" + * android:enabled="true" + * android:icon="@drawable/compose_icon" + * android:shortcutShortLabel="@string/compose_shortcut_short_label1" + * android:shortcutLongLabel="@string/compose_shortcut_long_label1" + * android:shortcutDisabledMessage="@string/compose_disabled_message1"> + * <intent + * android:action="android.intent.action.VIEW" + * android:targetPackage="com.example.myapplication" + * android:targetClass="com.example.myapplication.ComposeActivity" /> + * <!-- If your shortcut is associated with multiple intents, include them + * here. The last intent in the list is what the user sees when they + * launch this shortcut. --> + * <categories android:name="android.shortcut.conversation" /> + * </shortcut> + * <!-- Specify more shortcuts here. --> + *</shortcuts> ** - * The following list includes descriptions for the different attributes within a manifest shortcut: + * The following list includes descriptions for the different attributes within a static shortcut: *
+ * Apps can publish dynamic shortcuts with {@link #setDynamicShortcuts(List)} * or {@link #addDynamicShortcuts(List)}. The {@link #updateShortcuts(List)} method can also be * used to update existing, mutable shortcuts. * Use {@link #removeDynamicShortcuts(List)} or {@link #removeAllDynamicShortcuts()} to remove * dynamic shortcuts. * - *
Example: + *
The following code snippet shows how to create a single dynamic shortcut: *
- * ShortcutManager shortcutManager = getSystemService(ShortcutManager.class);
+ *ShortcutManager shortcutManager = getSystemService(ShortcutManager.class);
*
- * ShortcutInfo shortcut = new ShortcutInfo.Builder(this, "id1")
- * .setIntent(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.mysite.com/")))
- * .setShortLabel("Web site")
- * .setLongLabel("Open the web site")
- * .setIcon(Icon.createWithResource(context, R.drawable.icon_website))
- * .build();
+ *ShortcutInfo shortcut = new ShortcutInfo.Builder(this, "id1")
+ * .setShortLabel("Web site")
+ * .setLongLabel("Open the web site")
+ * .setIcon(Icon.createWithResource(context, R.drawable.icon_website))
+ * .setIntent(new Intent(Intent.ACTION_VIEW,
+ * Uri.parse("https://www.mysite.example.com/")))
+ * .build();
*
- * shortcutManager.setDynamicShortcuts(Arrays.asList(shortcut));
+ *shortcutManager.setDynamicShortcuts(Arrays.asList(shortcut));
*
*
*
* * Dynamic shortcuts can be published with any set of {@link Intent#addFlags Intent} flags. * Typically, {@link Intent#FLAG_ACTIVITY_CLEAR_TASK} is specified, possibly along with other - * flags; otherwise, if the application is already running, the application is simply brought to + * flags; otherwise, if the app is already running, the app is simply brought to * the foreground, and the target activity may not appear. * *
The {@link ShortcutInfo.Builder#setIntents(Intent[])} method can be used instead of * {@link ShortcutInfo.Builder#setIntent(Intent)} with {@link android.app.TaskStackBuilder} * in order to launch an activity with other activities in the back stack. * When the user selects a shortcut to load an activity with a back stack, - * then presses the back key, a "parent" activity will be shown instead of the user being - * navigated back to the launcher. + * then presses the back key, a parent activity from the same app will be shown + * instead of the user being navigated back to the launcher. * - *
Manifest shortcuts can also have multiple intents to achieve the same effect. + *
Static shortcuts can also have multiple intents to achieve the same effect.
* In order to associate multiple {@link Intent} objects with a shortcut, simply list multiple
* <intent> elements within a single <shortcut> element.
- * The last intent specifies what the user will see when they launch a shortcut.
+ * The last intent specifies what the user sees when they launch a shortcut.
*
- *
Manifest shortcuts cannot have custom intent flags. - * The first intent of a manifest shortcut will always have {@link Intent#FLAG_ACTIVITY_NEW_TASK} + *
Static shortcuts cannot have custom intent flags.
+ * The first intent of a static shortcut will always have {@link Intent#FLAG_ACTIVITY_NEW_TASK}
* and {@link Intent#FLAG_ACTIVITY_CLEAR_TASK} set.
- * This means, when the application is already running, all the existing activities will be
- * destroyed when a manifest shortcut is launched.
+ * This means, when the app is already running, all the existing activities will be
+ * destroyed when a static shortcut is launched.
* If this behavior is not desirable, you can use a trampoline activity,
* or an invisible activity that starts another activity in {@link Activity#onCreate},
* then calls {@link Activity#finish()}.
* The first activity should include an attribute setting
- * of {@code android:taskAffinity=""} in the application's AndroidManifest.xml
- * file, and the intent within the manifest shortcut should point at this first activity.
+ * of {@code android:taskAffinity=""} in the app's AndroidManifest.xml
+ * file, and the intent within the static shortcut should point at this first activity.
*
*
*
* In order to avoid confusion, you should not use {@link #updateShortcuts(List)} to update * a shortcut so that it contains conceptually different information. * - *
For example, a phone application may publish the most frequently called contact as a dynamic - * shortcut. Over time, this contact may change; when it does, the application should + *
For example, a phone app may publish the most frequently called contact as a dynamic + * shortcut. Over time, this contact may change. When it does, the app should * represent the changed contact with a new shortcut that contains a different ID, using either * {@link #setDynamicShortcuts(List)} or {@link #addDynamicShortcuts(List)}, rather than updating * the existing shortcut with {@link #updateShortcuts(List)}. @@ -291,7 +302,7 @@ import java.util.List; * it to reference a different contact will likely confuse the user. * *
On the other hand, when the - * contact's information has changed, such as the name or picture, the application should + * contact's information has changed, such as the name or picture, the app should * use {@link #updateShortcuts(List)} so that the pinned shortcut is updated too. * * @@ -299,21 +310,21 @@ import java.util.List; * When the launcher displays the shortcuts that are associated with a particular launcher icon, * the shortcuts should appear in the following order: *
Shortcut ranks are non-negative sequential integers + *
Shortcut ranks are non-negative, sequential integers * that determine the order in which shortcuts appear, assuming that the shortcuts are all in * the same category. * Ranks of existing shortcuts can be updated with - * {@link #updateShortcuts(List)}; you can use {@link #addDynamicShortcuts(List)} and - * {@link #setDynamicShortcuts(List)}, too. + * {@link #updateShortcuts(List)}. You can also use {@link #addDynamicShortcuts(List)} and + * {@link #setDynamicShortcuts(List)}. * *
Ranks are auto-adjusted so that they're unique for each target activity in each category - * (dynamic or manifest). For example, if there are 3 dynamic shortcuts with ranks 0, 1 and 2, + * (static or dynamic). For example, if there are 3 dynamic shortcuts with ranks 0, 1 and 2, * adding another dynamic shortcut with a rank of 1 represents a request to place this shortcut at * the second position. * In response, the third and fourth shortcuts move closer to the bottom of the shortcut list, @@ -321,119 +332,120 @@ import java.util.List; * *
* Calls to {@link #setDynamicShortcuts(List)}, {@link #addDynamicShortcuts(List)}, and - * {@link #updateShortcuts(List)} may be rate-limited when called by background applications, or - * applications with no foreground activity or service. When you attempt to call these methods - * from a background application after exceeding the rate limit, these APIs return {@code false}. + * {@link #updateShortcuts(List)} may be rate-limited when called by background apps, or + * apps with no foreground activity or service. When you attempt to call these methods + * from a background app after exceeding the rate limit, these APIs return {@code false}. * - *
Applications with a foreground activity or service are not rate-limited. + *
Apps with a foreground activity or service are not rate-limited. * - *
Rate-limiting will be reset upon certain events, so that even background applications - * can call these APIs again until the rate limit is reached again. + *
Rate-limiting is reset upon certain events, so that even background apps + * can call these APIs until the rate limit is reached again. * These events include the following: *
When rate-limiting is active, {@link #isRateLimitingActive()} returns {@code true}. * *
- * adb shell cmd shortcut reset-throttling [ --user USER-ID ] + *+ * If your app is rate-limited during development or testing, you can use the + * Reset ShortcutManager rate-limiting development option or + * the following {@code adb} command to reset it: + *
+ *$ adb shell cmd shortcut reset-throttling [ --user USER-ID ] ** *Handling System Locale Changes
* - * Applications should update dynamic and pinned shortcuts when the system locale changes + *+ * Apps should update dynamic and pinned shortcuts when the system locale changes * using the {@link Intent#ACTION_LOCALE_CHANGED} broadcast. * - *
When the system locale changes, rate-limiting is reset, so even background applications - * can set dynamic shortcuts, add dynamic shortcuts, and update shortcuts until the rate limit - * is reached again. + *
When the system locale changes, rate-limiting is reset, so even background apps + * can add and update dynamic shortcuts until the rate limit is reached again. * * *
Backup and Restore
* - * When an application has the {@code android:allowBackup="true"} attribute assignment included + *+ * When an app has the {@code android:allowBackup="true"} attribute assignment included * in its
AndroidManifest.xmlfile, pinned shortcuts are * backed up automatically and are restored when the user sets up a new device. * - *Categories of Shortcuts that are Backed Up
+ *Categories of shortcuts that are backed up
* *
AndroidManifest.xml file, anyway.
+ * AndroidManifest.xml file.
*
- * Because dynamic shortcuts are not restored, it is recommended that applications check + *
Because dynamic shortcuts are not restored, it is recommended that apps check * currently-published dynamic shortcuts using {@link #getDynamicShortcuts()} * each time they are launched, and they should re-publish * dynamic shortcuts when necessary. * *
- * public class MainActivity extends Activity {
- * public void onCreate(Bundle savedInstanceState) {
- * super.onCreate(savedInstanceState);
+ *public class MainActivity extends Activity {
+ * public void onCreate(Bundle savedInstanceState) {
+ * super.onCreate(savedInstanceState);
+ * ShortcutManager shortcutManager =
+ * getSystemService(ShortcutManager.class);
*
- * ShortcutManager shortcutManager = getSystemService(ShortcutManager.class);
- *
- * if (shortcutManager.getDynamicShortcuts().size() == 0) {
- * // Application restored; re-publish dynamic shortcuts.
- *
- * if (shortcutManager.getPinnedShortcuts().size() > 0) {
- * // Pinned shortcuts have been restored. Use updateShortcuts() to make sure
- * // they have up-to-date information.
- * }
- * }
- * }
- * :
- *
- * }
+ * if (shortcutManager.getDynamicShortcuts().size() == 0) {
+ * // Application restored. Need to re-publish dynamic shortcuts.
+ * if (shortcutManager.getPinnedShortcuts().size() > 0) {
+ * // Pinned shortcuts have been restored. Use
+ * // updateShortcuts() to make sure they contain
+ * // up-to-date information.
+ * }
+ * }
+ * }
+ * // ...
+ *}
*
*
*
* + * Because pinned shortcuts are backed up and restored on new devices, shortcut IDs + * should contain either stable, constant strings or server-side identifiers, * rather than identifiers generated locally that might not make sense on other devices. * * *
+ * Launcher apps may be capable of predicting which shortcuts will most likely be * used at a given time by examining the shortcut usage history data. * - *
In order to provide launchers with such data, publisher applications should + *
In order to provide launchers with such data, publisher apps should * report the shortcuts that are used with {@link #reportShortcutUsed(String)} * when a shortcut is selected, * or when an action equivalent to a shortcut is taken by the user even if it wasn't started * with the shortcut. * - *
For example, suppose a GPS navigation application supports "navigate to work" as a shortcut. + *
For example, suppose a navigation app supports "navigate to work" as a shortcut. * It should then report when the user selects this shortcut and when the user chooses - * to navigate to work within the application itself. - * This helps the launcher application + * to navigate to work within the app itself. + * This helps the launcher app * learn that the user wants to navigate to work at a certain time every * weekday, and it can then show this shortcut in a suggestion list at the right time. * *
See the class level javadoc for details. * @@ -769,13 +781,13 @@ public class ShortcutManager { } /** - * Applications that publish shortcuts should call this method - * whenever the user selects the shortcut containing the given ID or when the user completes - * an action in the application that is equivalent to selecting the shortcut. + * Apps that publish shortcuts should call this method whenever the user + * selects the shortcut containing the given ID or when the user completes + * an action in the app that is equivalent to selecting the shortcut. * For more details, see the Javadoc for the {@link ShortcutManager} class * *
The information is accessible via {@link UsageStatsManager#queryEvents} - * Typically, launcher applications use this information to build a prediction model + * Typically, launcher apps use this information to build a prediction model * so that they can promote the shortcuts that are likely to be used at the moment. * * @throws IllegalStateException when the user is locked. @@ -790,9 +802,9 @@ public class ShortcutManager { } /** - * Called internally when an application is considered to have come to foreground + * Called internally when an app is considered to have come to the foreground * even when technically it's not. This method resets the throttling for this package. - * For example, when the user sends an "inline reply" on an notification, the system UI will + * For example, when the user sends an "inline reply" on a notification, the system UI will * call it. * * @hide