android developer android developer - 1 year ago 155
Android Question

How to correctly create static App-Shortcut on Android 7.1 ?


Android 7.1 now has a new feature called "AppShortcut" . On the docs, they explain how to create static ones and dynamic ones, and they even have a sample app.

The problem

I tried out the sample, yet I've noticed that when I click on the static app-shortcut, it shows me a toast "app isn't installed".

enter image description here

Looking at the code, I've found a suspicious configuration (in "shortcuts.xml" file) :

<shortcuts xmlns:android="" >

It doesn't look good, because nothing in the app has this intent action of "ADD_WEBSITE" .

The dynamic shortcuts work fine btw (can be added via the normal launch of MainActivity).

What I tried

So I thought this should be changed. I tried to create a new activity and change this configuration to match the activity (action and targetCalss), but for some reason I still got the same toast .

The question

What could be wrong in the code? What should be changed to fix it?

Answer Source

It's strange, but you can fix it by change
android:targetPackage = "" (same as applicationid) or
applicationId "" (same as package name).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download