0

在Android 7.1中,应用程序快捷方式(“快捷方式”)可以定义为shortcuts.xml资源文件中的intent,然后在应用程序的AndroidManifest.xml文件的元数据标记中引用该文件。然后,Action Launcher应用程序可以使用“静态快捷方式”意图启动一个应用程序,其中包含一个在intent中定义的特定活动。从运行时执行的Java代码中,我将如何获得在任意应用程序的AndroidManifest.xml和shortcuts.xml资源文件中定义的所有静态快捷方式意图?如何在运行时获取所有已安装应用程序的静态快捷方式(快捷方式)的内容?

+0

我从来没有直接与他们合作,所以我不能发布代码,但它使用了'LauncherApps'类。我找不到如何获得一个https://developer.android.com/reference/android/content/pm/LauncherApps.html – Budius

+0

找到它。您可以调用'getSystemService(Context.LAUNCHER_APPS_SERVICE)'并使用'getShortcuts'查询。 – Budius

回答

0

你的意思是你想获得你的运行时代码的静态快捷方式?
也许你可以参考代码如下,希望本文能帮助ü

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