<shortcuts xmlns:android="http://schemas.android.com/apk/res/android">
<shortcut
android:shortcutId="compose"
android:enabled="true"
android:icon="@drawable/compose_icon"
android:shortcutShortLabel="@string/compose_shortcut_short_label1"
android:shortcutLongLabel="@string/compose_shortcut_long_label1"
android:shortcutDisabledMessage="@string/compose_disabled_message1">
<intent
android:action="android.intent.action.VIEW"
android:targetPackage="com.example.myapplication"
android:targetClass="com.example.myapplication.ComposeActivity" />
<!-- This -->
<categories android:name="android.shortcut.conversation" />
</shortcut>
</shortcuts>
还有什么其他价值?我需要包括这个类别吗?如果我删除它呢?
我在官方文件中没有找到这个-https://developer.android.com/guide/topics/ui/shortcuts.html
最佳答案
categories
标记用于为应用程序快捷方式执行的操作类型提供分组。其中一个可用组是android.shortcut.conversation
,如果要添加聊天应用程序会话的快捷方式,则使用此选项。例如,最近聊天记录的快捷方式。您只需在shortcuts.xml中添加此项,就可以提供上述快捷方式。否则你就不需要了。你可以删除它。
对于API级别26或更低的版本,这是唯一可用的值。但对于更高的版本有多种。
有关支持的快捷方式类别的列表,您可以看到this页。