gpt4 book ai didi

Android - PackageManager 标志

转载 作者:太空狗 更新时间:2023-10-29 15:03:56 27 4
gpt4 key购买 nike

我正在浏览 PackageManager API。我发现定义了以下常量:

1) GET_DISABLED_COMPONENTS
2) GET_DISABLED_UNTIL_USED_COMPONENTS
3) COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED
4) COMPONENT_ENABLED_STATE_DISABLED_USER
5) COMPONENT_ENABLED_STATE_DISABLED
6) COMPONENT_ENABLED_STATE_DEFAULT
7) COMPONENT_ENABLED_STATE_ENABLED
8) GET_UNINSTALLED_PACKAGES

阅读documentation ,我看到对于常量 5-7,一个组件已被启用/禁用,而不管它在 list 文件中是如何指定的。

对于 3,文档说:

This application should be considered, until the point where the user actually
wants to use it.

这是什么意思?

对于 4,文档说:

The user has explicitly disabled the application, regardless of what it has 
specified in its manifest.

如果此标志与应用程序相关,为什么名称以“COMPONENT”开头?另外,用户如何禁用该应用程序?

对于 8,文档说:

Flag parameter to retrieve some information about all applications (even 
uninstalled ones) which have data directories. This state could have
resulted if applications have been deleted with flag DONT_DELETE_DATA with
a possibility of being replaced or reinstalled in future.

DONT_DELETE_DATA 标志在哪里指定?

总而言之,如果有人可以为开发人员解释这些常量的用例,那将会很有帮助。

谢谢。

最佳答案

我在我的一个项目中使用它们。在这里查看。 https://github.com/slightfoot/android-launcher-badges

不确定是否有帮助。

编辑:您会看到此处使用的大部分标志:AppBadge.java其余的都是不言自明的。 The documentation似乎很好地描述了一切。

  1. COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED(已添加到 API 级别 18)

    它提到的示例似乎足以解释可能的用例。

    Flag for setApplicationEnabledSetting(String, int, int) only: This application should be considered, until the point where the user actually wants to use it. This means that it will not normally show up to the user (such as in the launcher), but various parts of the user interface can use GET_DISABLED_UNTIL_USED_COMPONENTS to still see it and allow the user to select it (as for example an IME, device admin, etc). Such code, once the user has selected the app, should at that point also make it enabled. This option currently can not be used with setComponentEnabledSetting(ComponentName, int, int).

  2. COMPONENT_ENABLED_STATE_DISABLED_USER (已添加到 API 级别 14)

    它们似乎被设计为最终与 setComponentEnabledSetting 一起使用,但目前它们不能。这是为了向前兼容,文档说明您可以使用 setApplicationEnabledSetting

    Flag for setApplicationEnabledSetting(String, int, int) only: The user has explicitly disabled the application, regardless of what it has specified in its manifest. Because this is due to the user's request, they may re-enable it if desired through the appropriate system UI. This option currently cannot be used with setComponentEnabledSetting(ComponentName, int, int).

  3. DONT_DELETE_DATA 标志已重命名为 DELETE_KEEP_DATA 并且文档尚未更新。它已被标记为 @hide,因为它不供公共(public)开发人员使用。

    /**
    * Flag parameter for {@link #deletePackage} to indicate that you don't want to delete the
    * package's data directory.
    *
    * @hide
    */
    public static final int DELETE_KEEP_DATA = 0x00000001;

关于Android - PackageManager 标志,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23686490/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com