AppFunctionUriValueConstraint


@Retention(value = AnnotationRetention.BINARY)
@Target(allowedTargets = [AnnotationTarget.VALUE_PARAMETERAnnotationTarget.FUNCTIONAnnotationTarget.PROPERTY])
public annotation AppFunctionUriValueConstraint


Specifies constraints applied on android.net.Uri values for parameters, return types, or properties in app functions.

This annotation can be applied to:

At compile time, the compiler translates this constraint into an androidx.appfunctions.metadata.AppFunctionStringTypeMetadata object with:

Usage Example:

// Constraining a parameter:
@AppFunction
fun updateWallpaper(
@AppFunctionUriValueConstraint(allowedSchemes = ["content"])
wallpaperUri: Uri
) {
// Function body
}

// Constraining a function return value:
@AppFunction
@AppFunctionUriValueConstraint(allowedSchemes = ["content"])
fun getProfilePictureUri(): Uri {
// Function body
}

// Constraining a property within an AppFunctionSerializable:
@AppFunctionSerializable
data class WallpaperConfig(
@property:AppFunctionUriValueConstraint(allowedSchemes = ["content"])
val wallpaperUri: Uri
)

Summary

Public constructors

AppFunctionUriValueConstraint(@NonNull String[] allowedSchemes)

Public methods

final @NonNull String[]

The list of allowed URI schemes for the annotated element defined by the developer (e.g. ["content"] or custom schemes such as ["photo", "video"]).

Public constructors

AppFunctionUriValueConstraint

Added in 1.0.0-alpha12
public AppFunctionUriValueConstraint(@NonNull String[] allowedSchemes)

Public methods

getAllowedSchemes

public final @NonNull String[] getAllowedSchemes()

The list of allowed URI schemes for the annotated element defined by the developer (e.g. ["content"] or custom schemes such as ["photo", "video"]).

At compile time, this list is translated into a regular expression matching the specified schemes (for example, ^content:.* when allowedSchemes = ["content"]). If empty, any URI scheme is permitted.