Android - how to add @hide annotation in my project

六眼飞鱼酱① 提交于 2019-11-27 02:56:10

问题


I'm developing SDK, and I would like to use @hide annotation for methods/classes which I don't want to be visible for the user who uses my SDK. (same as in Activity implementation - line 3898)

I tried just to add @hide annotation but I saw that nothing happens. What should I need to do in order to use @hide annotation/or any other similar solution for encapsulating my internal SDK's classes/methods.


回答1:


In Android SDK, the @hide annotation is only used when building the stub version of android.jar. At compile-time symbols are imported from this stub jar and only non-hidden symbols are available. At runtime in device or emulator the symbols are there in the platform libraries and they can be seen for example via reflection.

If your SDK only consists of a jar file or something similar, there really isn't a way to hide symbols in it.



来源:https://stackoverflow.com/questions/25722945/android-how-to-add-hide-annotation-in-my-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!