我开始使用 AppShortcuts,根据离线文档的要求创建所有内容:
<shortcuts xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:targetApi="25">
<shortcut
android:enabled="true"
android:icon="@drawable/ic_category_transfer"
android:shortcutId="shortcut_name"
android:shortcutShortLabel="@string/common_transactions_add_transaction">
<intent
android:action="android.intent.action.VIEW"
android:targetClass=".LauncherActivity"
android:targetPackage="com.sai.android">
</intent>
<categories android:name="android.shortcut.conversation" />
</shortcut>
在模拟器中测试,出现带有文本的图标,但是当您尝试浏览此选项卡时,它会显示文本
应用程序未安装
虽然安装了应用程序。也许是 attribute android:action
,因为我还没有完全弄明白。
检查清单中的应用程序包名称是否匹配
android:targetPackage="com.sai.android"
并在此处指定保真度类的完整路径
android:targetClass=".LauncherActivity"
回答问题的附录:
由于您有主要活动,因此您可以通过它获得所需的片段。
首先,您仍应确保属性在
shortcuts.xml
. 它看起来像这样:并且已经在您的活动中,您将必须在方法中实施以下构造
onCreate()
:当然,再次确保您
AndroidManifest.xml
在主要活动中intent'e
写入以下内容meta-data
:另请参阅更多详细信息:
应用程序快捷方式;
快捷方式管理器;
快捷信息生成器。