java - Android 7.1应用程序快捷方式

标签 java android

我使用静态快捷方式如下(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/

相关文章:

java - 当 MDB 尝试连接到远程队列时,WebSphere 8 中出现异常

Java JDBC 忽略 setFetchSize?

android - SearchView 风格干扰 Toolbar Style Actionbar

java - 如何在RMI项目中添加多线程?

java - 使用 Id Autowiring tcp-outbound-channel-adapter 不起作用

java - LinkedHashSet 等于方法

java - 在代码中进行更改后,模拟器未显示更新的输出

android - 如何在Android中同时录制声音和读取声音

android - 使用 Android XML 的节标题?

android - 自定义首选项 - 按钮不可点击