diff --git a/core/java/android/content/pm/ShortcutManager.java b/core/java/android/content/pm/ShortcutManager.java index b992d29eb32f9..a7c09b50ffa9b 100644 --- a/core/java/android/content/pm/ShortcutManager.java +++ b/core/java/android/content/pm/ShortcutManager.java @@ -17,8 +17,6 @@ package android.content.pm; import android.annotation.NonNull; import android.annotation.Nullable; -import android.annotation.SdkConstant; -import android.annotation.SdkConstant.SdkConstantType; import android.annotation.TestApi; import android.annotation.UserIdInt; import android.app.Activity; @@ -26,15 +24,12 @@ import android.app.usage.UsageStatsManager; import android.content.Context; import android.content.Intent; import android.content.IntentSender; -import android.os.Binder; -import android.os.Parcel; -import android.os.Parcelable; +import android.os.Build.VERSION_CODES; import android.os.RemoteException; import android.os.ServiceManager; import android.os.UserHandle; import com.android.internal.annotations.VisibleForTesting; -import com.android.internal.util.Preconditions; import java.util.List; @@ -289,6 +284,12 @@ import java.util.List; *
Note: If the user doesn't allow the shortcut to be pinned to the launcher, the * pinning process fails, and the {@link Intent} object that is passed into this * {@link android.app.PendingIntent} object isn't executed. + *
Note: Due to background execution limits introduced in Android + * {@link VERSION_CODES#O}, it's best to use a + * + * manifest-declared receiver to receive a callback. + *
Also, to prevent other apps from invoking the receiver, add the attribute assignment
+ * android:exported="false" to the receiver's manifest entry.
Note: The return value may change in subsequent calls, if the user changes + * the default launcher app. */ public boolean isRequestPinShortcutSupported() { try { @@ -952,6 +954,8 @@ public class ShortcutManager { * set. * @param resultIntent If not null, this intent will be sent when the shortcut is pinned. * Use {@link android.app.PendingIntent#getIntentSender()} to create an {@link IntentSender}. + * To avoid background execution limits, use an unexported, manifest-declared receiver. + * For more details, see the overview documentation for the {@link ShortcutManager} class. * * @return {@code TRUE} if the launcher supports this feature. Note the API will return without * waiting for the user to respond, so getting {@code TRUE} from this API does *not* mean