Search code examples
androidandroid-intentandroid-widgetandroid-shortcut

Can I prevent a shortcut (android.intent.action.CREATE_SHORTCUT) to appear in the add widget section of the launcher?


If you start my app you see a list of products, and if you select an item I open a product page.

Since some of my customers use the app always with the same product, I added a "add to homescreen" option to each product page. This creates a shortcut on the launcher. I did this according as described in this issue:

How can I have a home screen shortcut launch a dialog?

The shortcut works great, but I noticed that my app now has a "widget", that the user can add to the home screen from the installed app launcher. Doing so does not create a valid shortcut, because the information which product should be opened is not set this way.

I don't want this widget there in the first place, is there a way to create a shortcut without also adding the widget?


Solution

  • I'd recommend fixing the widget so you can create a shortcut to a product from there, in addition to the "Add to home screen" menu option. However if you don't want to do this simply remove the android.intent.action.CREATE_SHORTCUT intent-filter from the activity. You can still add a shortcut to the homescreen using the INSTALL_SHORTCUT permission with your existing method.