【发布时间】:2019-03-01 04:05:53
【问题描述】:
我正在构建一个具有系统权限的企业应用程序,它需要使用来自 BluetoothAdapter 类 setScanMode 的函数。这是一个隐藏的API,仅适用于系统签名的apk,现在这个函数上面有@UnsupportedAppUsage,谁能帮我理解这个注释。
【问题讨论】:
标签: android annotations android-source
我正在构建一个具有系统权限的企业应用程序,它需要使用来自 BluetoothAdapter 类 setScanMode 的函数。这是一个隐藏的API,仅适用于系统签名的apk,现在这个函数上面有@UnsupportedAppUsage,谁能帮我理解这个注释。
【问题讨论】:
标签: android annotations android-source
如果我们去annotation source:
/**
* 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}
*/
基本上,这意味着它正在被应用使用,即使它在技术上不是 SDK 的一部分,因此不受支持。对于任何为 AOSP 做出贡献的人来说,这似乎更像是一个警告,而不是您需要过多担心的事情。
【讨论】:
以上注解来源描述是正确的。我现在在我的 Pie 代码中遇到了一个以前没有的异常。我正在通过 TextView.class 中的某些字段设置光标处理程序颜色,这些字段现在不受支持,并导致在我无法在 Pie 中设置句柄颜色的位置发生异常。 这不仅仅是一个警告。
【讨论】: