新的@SystemApi 注释是什么意思,与@hide 有什么区别? [英] What's the meaning of new @SystemApi annotation, any difference from @hide?

查看:71
本文介绍了新的@SystemApi 注释是什么意思,与@hide 有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Android 最近在其 SDK 源代码中引入了 @SystemApi.看起来与之前的 @hide 注释效果相同,因为它们也从 SDK jar 类中剥离.

应用程序是否有可能以不同于旧的@hide API 的方式调用它们.

/*** 表示公开了一个 API 以供捆绑的系统应用程序使用.* <p>* 这些 API 不能保证在不同版本之间保持一致,* 并且不供与 Android SDK 链接的应用程序使用.* </p><p>* 此注释应仅出现在已标记为 

@hide

的 API 上.* </p>** @隐藏*/

解决方案

用@SystemApi 注释的方法是用@hide 注释的方法的子集.对于内部团队(可能也是合作伙伴)来说,这显然是一个指标,即这些方法是实际的 API,尽管不是针对公共开发者的.

这样一来,@SystemApi 的方法会比@hide 的方法更稳定,以后可以随时更改,无需考虑兼容性,也允许任何 OEM 自行更改.

>

如果您尝试通过反射调用内部 API,请始终首选 @SystemApi 方法以获得更好的未来兼容性.

Android introduced @SystemApi in its SDK source code recently. Seems like same in effect as the @hide annotation before, since they also got stripped from SDK jar classes.

Is there any chance an app can call them in ways different from the old @hide APIs.

/**
 * Indicates an API is exposed for use by bundled system applications.
 * <p>
 * These APIs are not guaranteed to remain consistent release-to-release,
 * and are not for use by apps linking against the Android SDK.
 * </p><p>
 * This annotation should only appear on API that is already marked <pre>@hide</pre>.
 * </p>
 *
 * @hide
 */

解决方案

Methods annotated with @SystemApi are a subset of ones with @hide. It's apparently an indicator for internal teams (perhaps also partners) that these methods are actual APIs, although not for public developers.

As a result, @SystemApi methods will be more stable than @hide ones, which could be changed at any time in the future without any compatibility consideration, and also any OEM is allowed to change them at their own will.

If you are trying to invoke internal APIs via reflection, always prefer @SystemApi methods for better future compatibility.

这篇关于新的@SystemApi 注释是什么意思,与@hide 有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆