getBooleanFlagValue

fun getBooleanFlagValue(packageName: String, flagName: String, defaultValue: Boolean = false): Boolean(source)

Retrieves the value of a boolean flag from the specified Aconfig Package.

If the specified Aconfig Package does not exist or the flag does not exist within the package, returns the provided defaultValue. Otherwise, returns the value of the flag.

The first call to a given Aconfig Package will result in a call to AconfigPackageCompat.load. Subsequent calls will use a cached package. Individual flag values are cached within AconfigPackageCompat.

Note: This method differs from calling AconfigPackageCompat directly in that it will return a default value rather than throw an exception in the event of an error.

Platform-specific behavior:

  • Prior to API level 36, this method always returns defaultValue

Return

The boolean value of the flag, or defaultValue if the flag is not found.

Parameters

flagName

The name of the flag (excluding any package name prefix).

defaultValue

The value to return if the flag is not found.