I'm retreiving all possible shortcuts from the system like following:
val pm = context.getPackageManager()
val shortcutsIntent = Intent(Intent.ACTION_CREATE_SHORTCUT)
val ril = pm.queryIntentActivities(shortcutsIntent, 0)
// I progress this data and show my users a custom dialog with apps
// and possible shortcuts and then will start the shortcut setup with ACTION_CREATE_SHORTCUT intent
The problem here is, that on android O or higher, above e.g also returns new static shortcuts - for which an app needs to be the default launcher as far as I know. Can I somehow filter them out?
I have a sidebar like app and only can support normal shortcuts and cannot support newer static/dynamic shortcuts because of the missing permission...
Example
Gmail e.g. offers shortcuts to labels - I get this possible shortcut above. But if I start to set up the shortcut like following
val i = Intent(Intent.ACTION_CREATE_SHORTCUT)
i.addCategory(Intent.CATEGORY_DEFAULT)
i.component = ComponentName(packageName, activityName)
startActivityForResult(i, RequestCodes.SHORTCUT_CREATE_REQUEST_CODE)
and wait for the result, I do NOT get back an Intent
with Intent.EXTRA_SHORTCUT_INTENT
(and all the others like Intent.EXTRA_SHORTCUT_ICON
, ...) in it, but one with LauncherApps.EXTRA_PIN_ITEM_REQUEST
in it. But this is too late, I would like to remove this shortcut from the list above at all as I know that my app can't launch such a shortcut because of missing permissions...
from Get shortcuts WITHOUT new static/dynamic shortcuts
No comments:
Post a Comment