RestrictTo


@MustBeDocumented
@Retention(value = AnnotationRetention.BINARY)
@Target(allowedTargets = [AnnotationTarget.ANNOTATION_CLASS, AnnotationTarget.CLASS, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER, AnnotationTarget.CONSTRUCTOR, AnnotationTarget.FIELD, AnnotationTarget.FILE])
public annotation RestrictTo


Denotes that the annotated element should only be accessed from within a specific scope (as defined by Scope).

Example of restricting usage within a library (based on Gradle group ID):

@RestrictTo(GROUP_ID)
public void resetPaddingToInitialValues() { ...

Example of restricting usage to tests:

@RestrictTo(Scope.TESTS)
public abstract int getUserId();

Example of restricting usage to subclasses:

@RestrictTo(Scope.SUBCLASSES)
public void onDrawForeground(Canvas canvas) { ...

Summary

Nested types

public enum RestrictTo.Scope extends Enum

Public constructors

Public methods

final @NonNull RestrictTo.Scope[]

The scope(s) to which usage should be restricted.

Public constructors

RestrictTo

public RestrictTo(@NonNull RestrictTo.Scope value)

Public methods

getValue

public final @NonNull RestrictTo.Scope[] getValue()

The scope(s) to which usage should be restricted.

android is a command-line tool located in the tools directory of the Android SDK.

Updated Apr 12, 2023

Welcome to Android 4.3, a sweeter version of Jelly Bean! Android 4.3 includes performance optimizations and great new features for users and developers. This document provides a glimpse of what's new for developers. See the Android 4.3 APIs document…

Updated May 20, 2024

Discover the latest app development tools, platform updates, training, and documentation for developers across every Android device.

Updated Dec 18, 2024