背景
Android 7.1现在有一个名为“AppShortcut”的新功能。在文档中,他们解释了如何创建静态和动态快捷方式,并且甚至有一个示例应用程序。
问题
我尝试了这个示例,但我注意到当我点击静态应用程序快捷方式时,它会显示一个toast消息"应用未安装"。
查看代码,我发现一个可疑的配置(在 "shortcuts.xml" 文件中):
<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>
这不太好,因为应用程序中没有"ADD_WEBSITE"的意图操作。
动态快捷方式可以正常工作(可以通过MainActivity的普通启动添加)。
我尝试过的
所以我认为这应该被更改。我尝试创建一个新的活动并更改此配置以匹配活动(操作和targetCalss),但由于某种原因我仍然收到相同的提示。
问题
代码中可能有什么问题?应该更改什么来修复它?