Background
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".
Looking at the code, I've found a suspicious configuration (in "shortcuts.xml" file) :
<shortcuts xmlns:android="http://schemas.android.com/apk/res/android" >
<shortcut
android:shortcutId="add_website"
android:icon="@drawable/add"
android:shortcutShortLabel="@string/add_new_website_short"
android:shortcutLongLabel="@string/add_new_website"
>
<intent
android:action="com.example.android.appshortcuts.ADD_WEBSITE"
android:targetPackage="com.example.android.appshortcuts"
android:targetClass="com.example.android.appshortcuts.Main"
/>
</shortcut>
</shortcuts>
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?
It's strange, but you can fix this by changing
android:targetPackage = "com.example.android.shortcutsample"
(same as applicationid) orapplicationId "com.example.android.appshortcuts"
(same as package name).