Reputation: 116322
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.
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).
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 .
What could be wrong in the code? What should be changed to fix it?
Upvotes: 3
Views: 1947
Reputation: 844
It's strange, but you can fix this by changing
android:targetPackage = "com.example.android.shortcutsample"
(same as applicationid) or
applicationId "com.example.android.appshortcuts"
(same as package name).
Upvotes: 4
Reputation: 669
Because your "com.example.android.appshortcuts.Main" don't has this action
com.example.android.appshortcuts.ADD_WEBSITE
You can change this action to
android.intent.action.VIEW
Upvotes: 0