java – How to support shortcut pinning in a custom Launcher?-ThrowExceptions

Exception or error:

I’m making my own Android launcher and I want to react to requests from other apps to add a shortcut to home screen.

So far, I was only able to find out, that apps have to check if shortcut pinning is supported by calling isRequestPinShortcutSupported() from ShortcutManager and then send a request by calling requestPinShortcut() – but how do I implement the other side of that?

I don’t know how to tell ShortcutManager my launcher wants to receive these requests and where to handle them. I have tried registering various BroadcastReceivers but that wasn’t enough.

Only helpful thing I could find was LauncherApps.PinItemRequest, that can be created from Intent, but I can’t find how do I receive this intent.

How to solve:

Okay, I had to study android source code for this but I figured out I need to create an Activity like this:

<activity android:name=".Activities.AddShortcutActivity">
        <action android:name="" />

And then in that Activity’s onCreate() I can call

LauncherApps().getPinItemRequest( this.getIntent() );

//handle request...


and do whatever I need with that request. Hope this helps someone.

Leave a Reply

Your email address will not be published. Required fields are marked *