@UnsupportedAppUsage注释描述了什么

Man*_*ika 6 android annotations android-source

我正在构建具有系统许可权的企业应用程序,它需要使用BluetoothAdapter类setScanMode中的功能。这是一个隐藏的API,仅适用于系统签名的apk,现在此函数上方有@UnsupportedAppUsage,任何人都可以帮助我理解此注释。

https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/bluetooth/BluetoothAdapter.java

The*_*rer 19

如果我们转到注释源

/**
 * Indicates that a class member, that is not part of the SDK, is used by apps.
 * Since the member is not part of the SDK, such use is not supported.
 *
 * <p>This annotation acts as a heads up that changing a given method or field
 * may affect apps, potentially breaking them when the next Android version is
 * released. In some cases, for members that are heavily used, this annotation
 * may imply restrictions on changes to the member.
 *
 * <p>This annotation also results in access to the member being permitted by the
 * runtime, with a warning being generated in debug builds.
 *
 * <p>For more details, see go/UnsupportedAppUsage.
 *
 * {@hide}
 */
Run Code Online (Sandbox Code Playgroud)

基本上,这意味着它正在被应用程序使用,即使它在技术上不是 SDK 的一部分,因此不受支持。对于任何为 AOSP 做出贡献的人来说,这似乎更像是一个警告,而不是您需要过多担心的事情。


小智 5

上述注释来源描述是正确的。现在,我的 Pie 代码中出现了一个异常,而以前则没有。我正在通过 TextView.class 中的某些字段设置光标处理程序颜色,这些字段现在不受支持,并导致在无法在 Pie 中设置句柄颜色的情况下发生异常。这不仅仅是一个警告。

  • 该标志只是一个警告。由于 Pie 中引入了隐藏的 API 黑名单,并且在 Q 中受到进一步限制,您遇到了错误。我在这里写了一些绕过此限制的方法:/sf/ask/3917909621/隐藏 api 限制 (3认同)