What does @hide mean in the Android source code?

What is the meaning of the keyword ?

Keywords are the unique words which are present in android source code to add a specific action for a function within an android application. Keywords are already defined with a certain set of actions to it. When we add a keyword in front of any function it will help to specify the action to it. There are different types of keywords used within android source code such as @hide, @findViewByID, public, private, @hide and many more.

In this article we will specifically take a look at the @hide keyword within our android application.

What does @hide mean in Android source code?

@hide is a keyword which is used in android source code that denotes a piece of code or a class that should not be the part of the public API. When an application uses this keyword, the code or a class is hidden from the public. It means that only this class can be accessed by the application that uses it. This keyword can be used by developers who want to limit the access to a certain feature of their application. This keyword was introduced in Android 2.3 (API level 9). It is used to hide the certain classes, fields as well as some methods from the public API and can be accessed by the application that uses it.

The @hide keyword is used for various reasons. For example, developers can use it to hide the code or classes that are still in development and not ready to be used publicly. It can also be used to hide the code that is specific to a particular device, such as code related to a specific hardware feature. Along with hiding code from the public API, @hide keyword can be used to hide certain features from Android Debug Bridge (ADB).

Where can we use @hide annotation in android?

The @hide annotation in Android is a powerful tool that can be used to hide a class, field, or method from the Android framework. It is especially useful when writing applications that need to interact with the Android framework but don't want to expose all of the internals of the code. One example of this is hiding certain classes or methods from the Android SDK that the application is using, or even hiding certain elements from the Android operating system itself. By using the @hide annotation, developers can easily restrict access to certain parts of the code while allowing other parts to remain open. This allows developers to create more secure applications that are more difficult to hack or tamper with.

Additionally, @hide can be used to improve performance by not having to include unnecessary code in the application. Ultimately, the @hide annotation is an invaluable tool for any Android developer looking to increase security and performance of their applications.

How to use the @hide keyword in Android Source Code?

The @hide keyword is a powerful tool for Android developers and can be used to ensure that internal APIs remain exclusive and are not exposed to the end user. This can be especially useful when developing highly complex applications and when using certain libraries that need to be hidden from the world. In order to use the @hide keyword, developers must first add the keyword to the API that they wish to keep hidden and then rebuild the application. This can be done either manually or through the use of the Gradle build system. Once the application is rebuilt, the API will be hidden from the end user and will remain exclusive to the developer.

In summary, the @hide keyword is an extremely useful tool for Android developers and can be used to ensure that internal APIs are kept exclusive and are not exposed to the end user. By using this keyword, developers can ensure that their applications remain secure and that no unauthorized access is gained.

Below is the example code snippet on How to use @hide keyword in Android Source Code

private @hide String imageUri = "";

Explanation - In the above code we are adding @hide annotation in front of the string variable named imageUri which will hide the access of this variable from other classes.


The annotation @hide in Android source code is a powerful tool for developers to use when creating apps for the Android platform. By using @hide, developers can indicate to the Android system that certain aspects of their app should be hidden from the user. This allows developers to create apps that are more secure and private by creating features that are not accessible to the user. Additionally, developers can use @hide to prevent the system from recognizing certain aspects of the app, such as permissions or activities. This can help to prevent malicious apps from gaining access to sensitive user data or services. By using @hide, developers can make sure that only the right parts of their app are visible to the user. This can help to create an experience that is both secure and enjoyable.

Updated on: 09-May-2023


Kickstart Your Career

Get certified by completing the course

Get Started