【问题标题】:How do I obtain Intents for static shortcuts (quickcuts) of all installed apps at runtime?如何在运行时获取所有已安装应用程序的静态快捷方式(快捷方式)的 Intent?
【发布时间】:2017-04-27 14:55:36
【问题描述】:

在 Android 7.1 中,有一些应用快捷方式(“quickcuts”)可以在快捷方式.xml 资源文件中定义为意图,然后在应用的 AndroidManifest.xml 文件的元数据标记中引用。然后,Action Launcher 应用程序可以使用“静态快捷方式”意图来启动具有在意图中定义的特定活动的应用程序。从运行时执行的 Java 代码中,我如何获得在任意应用的 AndroidManifest.xml 和 shortcuts.xml 资源文件中定义的所有此类静态快捷方式意图?

【问题讨论】:

  • 我从未直接与他们合作过,所以我无法发布代码,但它使用了LauncherApps 类。我找不到如何得到一个你developer.android.com/reference/android/content/pm/…
  • 找到了。您拨打getSystemService(Context.LAUNCHER_APPS_SERVICE) 并使用getShortcuts 进行查询。

标签: android android-manifest android-package-managers android-shortcut android-shortcutmanager


【解决方案1】:

您的意思是您想在运行时代码中获取静态快捷方式?
也许你可以参考下面的代码,希望对你有帮助

ShortcutManager shortcutManager = getSystemService(ShortcutManager.class);
List<ShortcutInfo> infos=shortcutManager.getManifestShortcuts();
    for(ShortcutInfo info : infos){
        info.getId());
        info.getLongLabel());
    }

【讨论】:

    猜你喜欢
    • 2011-09-06
    • 2010-10-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-07-07
    • 2021-04-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多