問題描述
Android 最近在其 SDK 源代碼中引入了@SystemApi.似乎與之前的 @hide 注釋效果相同,因為它們也被從 SDK jar 類中剝離.
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.
應用程序是否有可能以不同于舊的@hide API 的方式調用它們.
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
*/
推薦答案
帶有@SystemApi 注釋的方法是帶有@hide 的方法的子集.這顯然是內部團隊(可能也是合作伙伴)的一個指標,這些方法是實際的 API,盡管不是針對公共開發人員.
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.
因此,@SystemApi 方法將比 @hide 方法更穩定,將來可以隨時更改,無需任何兼容性考慮,并且任何 OEM 都可以隨意更改它們.
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.
如果您嘗試通過反射調用內部 API,請始終優先使用 @SystemApi 方法以實現更好的未來兼容性.
If you are trying to invoke internal APIs via reflection, always prefer @SystemApi methods for better future compatibility.
這篇關于新的@SystemApi 注解是什么意思,和@hide 有什么區別?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!