我使用静态快捷方式如下(shortcut.xml 的一部分)。
<shortcut
android:shortcutId="Noraml"
android:enabled="true"
android:icon="@drawable/ic_t_voice_list"
android:shortcutShortLabel="@string/sp_audio_effect_PrDdefault"
android:shortcutLongLabel="@string/sp_audio_effect_PrDdefault">
<intent
android:action="com.app.shortcuts.IVRService"
android:targetPackage="com.app.shortcuts"
android:targetClass="com.app.shortcuts.AppService">
</intent>
<!-- If your shortcut is associated with multiple intents, include them
here. The last intent in the list determines what the user sees when
they launch this shortcut. -->
<categories android:name="android.shortcut.conversation" />
</shortcut>
并在 list 文件中如下。
<service
android:name=".AppService"
android:enabled="true" >
<intent-filter>
<action android:name="com.app.shortcuts.IVRService" />
<action android:name="com.app.shortcuts.IVRRemoteService" />
</intent-filter>
</service>
但是当我尝试通过快捷方式启动应用程序时,我收到“应用程序未安装”消息。
快捷方式仅适用于 Activity 吗?或者我们可以在不启动应用程序的情况下在后台申请服务吗?
最佳答案
快捷方式只能启动 documentation 规定的 Activity :
Shortcuts provide users with quick access to activities other than an app's main activity in the currently-active launcher.
他们无法启动服务。
关于java - Android 7.1应用程序快捷方式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43131448/