Added in API level 1
Deprecated in API level 24

MockResources


open class MockResources : Resources
kotlin.Any
   ↳ android.content.res.Resources
   ↳ android.test.mock.MockResources

A mock android.content.res.Resources class. All methods are non-functional and throw java.lang.UnsupportedOperationException. Override it to provide the operations that you need.

Summary

Inherited constants
Public constructors

Public methods
open XmlResourceParser

open Int

open ColorStateList

open Configuration!

open Float

open Int

open Int

open DisplayMetrics!

open Drawable!

open Int
getIdentifier(name: String!, defType: String!, defPackage: String!)

open IntArray

open Int

open XmlResourceParser

open Movie!

open String
getQuantityString(id: Int, quantity: Int, vararg formatArgs: Any!)

open String
getQuantityString(id: Int, quantity: Int)

open CharSequence
getQuantityText(id: Int, quantity: Int)

open String!

open String!

open String!

open String!

open String

open String
getString(id: Int, vararg formatArgs: Any!)

open Array<String!>

open CharSequence
getText(id: Int)

open CharSequence!
getText(id: Int, def: CharSequence!)

open Array<CharSequence!>

open Unit
getValue(id: Int, outValue: TypedValue!, resolveRefs: Boolean)

open Unit
getValue(name: String!, outValue: TypedValue!, resolveRefs: Boolean)

open XmlResourceParser
getXml(id: Int)

open TypedArray!

open TypedArray

open InputStream

open AssetFileDescriptor!

open Unit

Inherited functions

Public constructors

MockResources

Added in API level 1
MockResources()

Public methods

getAnimation

Added in API level 1
open fun getAnimation(id: Int): XmlResourceParser

Deprecated: Deprecated in Java.

Parameters
id Int: The desired resource identifier, as generated by the aapt tool. This integer encodes the package, type, and resource entry. The value 0 is an invalid identifier.
Return
XmlResourceParser A new parser object through which you can read the XML data. This value cannot be null.
Exceptions
android.content.res.Resources.NotFoundException Throws NotFoundException if the given ID does not exist.

getColor

Added in API level 1
open fun getColor(id: Int): Int

Deprecated: Deprecated in Java.

Parameters
id Int: The desired resource identifier, as generated by the aapt tool. This integer encodes the package, type, and resource entry. The value 0 is an invalid identifier.
Return
Int A single color value in the form 0xAARRGGBB.
Exceptions
android.content.res.Resources.NotFoundException Throws NotFoundException if the given ID does not exist.

getColorStateList

Added in API level 1
open fun getColorStateList(id: Int): ColorStateList

Deprecated: Deprecated in Java.

Parameters
id Int: The desired resource identifier of a ColorStateList, as generated by the aapt tool. This integer encodes the package, type, and resource entry. The value 0 is an invalid identifier.
Return
ColorStateList A ColorStateList object containing either a single solid color or multiple colors that can be selected based on a state. This value cannot be null.
Exceptions
android.content.res.Resources.NotFoundException Throws NotFoundException if the given ID does not exist.

getConfiguration

Added in API level 1
open fun getConfiguration(): Configuration!

Deprecated: Deprecated in Java.

Return
Configuration! The resource's current configuration.

getDimension

Added in API level 1
open fun getDimension(id: Int): Float

Deprecated: Deprecated in Java.

Parameters
id Int: The desired resource identifier, as generated by the aapt tool. This integer encodes the package, type, and resource entry. The value 0 is an invalid identifier.
Return
Float Resource dimension value multiplied by the appropriate metric to convert to pixels.
Exceptions
android.content.res.Resources.NotFoundException Throws NotFoundException if the given ID does not exist.

getDimensionPixelOffset

Added in API level 1
open fun getDimensionPixelOffset(id: Int): Int

Deprecated: Deprecated in Java.

Parameters
id Int: The desired resource identifier, as generated by the aapt tool. This integer encodes the package, type, and resource entry. The value 0 is an invalid identifier.
Return
Int Resource dimension value multiplied by the appropriate metric and truncated to integer pixels.
Exceptions
android.content.res.Resources.NotFoundException Throws NotFoundException if the given ID does not exist.

getDimensionPixelSize

Added in API level 1
open fun getDimensionPixelSize(id: Int): Int

Deprecated: Deprecated in Java.

Parameters
id Int: The desired resource identifier, as generated by the aapt tool. This integer encodes the package, type, and resource entry. The value 0 is an invalid identifier.
Return
Int Resource dimension value multiplied by the appropriate metric and truncated to integer pixels.
Exceptions
android.content.res.Resources.NotFoundException Throws NotFoundException if the given ID does not exist.

getDisplayMetrics

Added in API level 1
open fun getDisplayMetrics(): DisplayMetrics!

Deprecated: Deprecated in Java.

Return
DisplayMetrics! The resource's current display metrics.

getDrawable

Added in API level 1
open fun getDrawable(id: Int): Drawable!

Deprecated: Deprecated in Java.

Parameters
id Int: The desired resource identifier, as generated by the aapt tool. This integer encodes the package, type, and resource entry. The value 0 is an invalid identifier.
Return
Drawable! Drawable An object that can be used to draw this resource.
Exceptions
android.content.res.Resources.NotFoundException Throws NotFoundException if the given ID does not exist.

getIdentifier

Added in API level 1
open fun getIdentifier(
    name: String!,
    defType: String!,
    defPackage: String!
): Int

Deprecated: Deprecated in Java.

Parameters
name String!: The name of the desired resource.
defType String!: Optional default resource type to find, if "type/" is not included in the name. Can be null to require an explicit type.
defPackage String!: Optional default package to find, if "package:" is not included in the name. Can be null to require an explicit package.
Return
Int int The associated resource identifier. Returns 0 if no such resource was found. (0 is not a valid resource ID.)

getIntArray

Added in API level 1
open fun getIntArray(id: Int): IntArray

Deprecated: Deprecated in Java.

Parameters
id Int: The desired resource identifier, as generated by the aapt tool. This integer encodes the package, type, and resource entry. The value 0 is an invalid identifier.
Return
IntArray The int array associated with the resource. This value cannot be null.
Exceptions
android.content.res.Resources.NotFoundException Throws NotFoundException if the given ID does not exist.

getInteger

Added in API level 1
open fun getInteger(id: Int): Int

Deprecated: Deprecated in Java.

Parameters
id Int: The desired resource identifier, as generated by the aapt tool. This integer encodes the package, type, and resource entry. The value 0 is an invalid identifier.
Return
Int Returns the integer value contained in the resource.
Exceptions
android.content.res.Resources.NotFoundException Throws NotFoundException if the given ID does not exist.

getLayout

Added in API level 1
open fun getLayout(id: Int): XmlResourceParser

Deprecated: Deprecated in Java.

Parameters
id Int: The desired resource identifier, as generated by the aapt tool. This integer encodes the package, type, and resource entry. The value 0 is an invalid identifier.
Return
XmlResourceParser A new parser object through which you can read the XML data. This value cannot be null.
Exceptions
android.content.res.Resources.NotFoundException Throws NotFoundException if the given ID does not exist.

getMovie

Added in API level 1
open fun getMovie(id: Int): Movie!

Deprecated: Deprecated in Java.

Parameters
id Int: The desired resource identifier, as generated by the aapt tool. This integer encodes the package, type, and resource entry. The value 0 is an invalid identifier.
Exceptions
android.content.res.Resources.NotFoundException Throws NotFoundException if the given ID does not exist.

getQuantityString

Added in API level 1
open fun getQuantityString(
    id: Int,
    quantity: Int,
    vararg formatArgs: Any!
): String

Deprecated: Deprecated in Java.

Parameters
id Int: The desired resource identifier, as generated by the aapt tool. This integer encodes the package, type, and resource entry. The value 0 is an invalid identifier.
quantity Int: The number used to get the correct string for the current language's plural rules.
formatArgs Any!: The format arguments that will be used for substitution.
Return
String String The string data associated with the resource, stripped of styled text information. This value cannot be null.
Exceptions
android.content.res.Resources.NotFoundException Throws NotFoundException if the given ID does not exist.

getQuantityString

Added in API level 1
open fun getQuantityString(
    id: Int,
    quantity: Int
): String

Deprecated: Deprecated in Java.

Parameters
id Int: The desired resource identifier, as generated by the aapt tool. This integer encodes the package, type, and resource entry. The value 0 is an invalid identifier.
quantity Int: The number used to get the correct string for the current language's plural rules.
Return
String String The string data associated with the resource, stripped of styled text information. This value cannot be null.
Exceptions
android.content.res.Resources.NotFoundException Throws NotFoundException if the given ID does not exist.

getQuantityText

Added in API level 1
open fun getQuantityText(
    id: Int,
    quantity: Int
): CharSequence

Deprecated: Deprecated in Java.

Parameters
id Int: The desired resource identifier, as generated by the aapt tool. This integer encodes the package, type, and resource entry. The value 0 is an invalid identifier.
quantity Int: The number used to get the correct string for the current language's plural rules.
Return
CharSequence CharSequence The string data associated with the resource, plus possibly styled text information. This value cannot be null.
Exceptions
android.content.res.Resources.NotFoundException Throws NotFoundException if the given ID does not exist.

getResourceEntryName

Added in API level 1
open fun getResourceEntryName(resid: Int): String!

Deprecated: Deprecated in Java.

Parameters
resid Int: The resource identifier whose entry name is to be retrieved.
Return
String! A string holding the entry name of the resource.
Exceptions
android.content.res.Resources.NotFoundException Throws NotFoundException if the given ID does not exist.

getResourceName

Added in API level 1
open fun getResourceName(resid: Int): String!

Deprecated: Deprecated in Java.

Parameters
resid Int: The resource identifier whose name is to be retrieved.
Return
String! A string holding the name of the resource.
Exceptions
android.content.res.Resources.NotFoundException Throws NotFoundException if the given ID does not exist.

getResourcePackageName

Added in API level 1
open fun getResourcePackageName(resid: Int): String!

Deprecated: Deprecated in Java.

Parameters
resid Int: The resource identifier whose package name is to be retrieved.
Return
String! A string holding the package name of the resource.
Exceptions
android.content.res.Resources.NotFoundException Throws NotFoundException if the given ID does not exist.

getResourceTypeName

Added in API level 1
open fun getResourceTypeName(resid: Int): String!

Deprecated: Deprecated in Java.

Parameters
resid Int: The resource identifier whose type name is to be retrieved.
Return
String! A string holding the type name of the resource.
Exceptions
android.content.res.Resources.NotFoundException Throws NotFoundException if the given ID does not exist.

getString

Added in API level 1
open fun getString(id: Int): String

Deprecated: Deprecated in Java.

Parameters
id Int: The desired resource identifier, as generated by the aapt tool. This integer encodes the package, type, and resource entry. The value 0 is an invalid identifier.
Return
String String The string data associated with the resource, stripped of styled text information. This value cannot be null.
Exceptions
android.content.res.Resources.NotFoundException Throws NotFoundException if the given ID does not exist.

getString

Added in API level 1
open fun getString(
    id: Int,
    vararg formatArgs: Any!
): String

Deprecated: Deprecated in Java.

Parameters
id Int: The desired resource identifier, as generated by the aapt tool. This integer encodes the package, type, and resource entry. The value 0 is an invalid identifier.
formatArgs Any!: The format arguments that will be used for substitution.
Return
String String The string data associated with the resource, stripped of styled text information. This value cannot be null.
Exceptions
android.content.res.Resources.NotFoundException Throws NotFoundException if the given ID does not exist.

getStringArray

Added in API level 1
open fun getStringArray(id: Int): Array<String!>

Deprecated: Deprecated in Java.

Parameters
id Int: The desired resource identifier, as generated by the aapt tool. This integer encodes the package, type, and resource entry. The value 0 is an invalid identifier.
Return
Array<String!> The string array associated with the resource. This value cannot be null.
Exceptions
android.content.res.Resources.NotFoundException Throws NotFoundException if the given ID does not exist.

getText

Added in API level 1
open fun getText(id: Int): CharSequence

Deprecated: Deprecated in Java.

Parameters
id Int: The desired resource identifier, as generated by the aapt tool. This integer encodes the package, type, and resource entry. The value 0 is an invalid identifier.
Return
CharSequence CharSequence The string data associated with the resource, plus possibly styled text information. This value cannot be null.
Exceptions
android.content.res.Resources.NotFoundException Throws NotFoundException if the given ID does not exist.

getText

Added in API level 1
open fun getText(
    id: Int,
    def: CharSequence!
): CharSequence!

Deprecated: Deprecated in Java.

Parameters
id Int: The desired resource identifier, as generated by the aapt tool. This integer encodes the package, type, and resource entry. The value 0 is an invalid identifier.
def CharSequence!: The default CharSequence to return.
Return
CharSequence! CharSequence The string data associated with the resource, plus possibly styled text information, or def if id is 0 or not found.

getTextArray

Added in API level 1
open fun getTextArray(id: Int): Array<CharSequence!>

Deprecated: Deprecated in Java.

Parameters
id Int: The desired resource identifier, as generated by the aapt tool. This integer encodes the package, type, and resource entry. The value 0 is an invalid identifier.
Return
Array<CharSequence!> The styled text array associated with the resource. This value cannot be null.
Exceptions
android.content.res.Resources.NotFoundException Throws NotFoundException if the given ID does not exist.

getValue

Added in API level 1
open fun getValue(
    id: Int,
    outValue: TypedValue!,
    resolveRefs: Boolean
): Unit

Deprecated: Deprecated in Java.

Parameters
id Int: The desired resource identifier, as generated by the aapt tool. This integer encodes the package, type, and resource entry. The value 0 is an invalid identifier.
outValue TypedValue!: Object in which to place the resource data.
resolveRefs Boolean: If true, a resource that is a reference to another resource will be followed so that you receive the actual final resource data. If false, the TypedValue will be filled in with the reference itself.
Exceptions
android.content.res.Resources.NotFoundException Throws NotFoundException if the given ID does not exist.

getValue

Added in API level 1
open fun getValue(
    name: String!,
    outValue: TypedValue!,
    resolveRefs: Boolean
): Unit

Deprecated: Deprecated in Java.

Parameters
name String!: The name of the desired resource. This is passed to getIdentifier() with a default type of "string".
outValue TypedValue!: Object in which to place the resource data.
resolveRefs Boolean: If true, a resource that is a reference to another resource will be followed so that you receive the actual final resource data. If false, the TypedValue will be filled in with the reference itself.
Exceptions
android.content.res.Resources.NotFoundException Throws NotFoundException if the given ID does not exist.

getXml

Added in API level 1
open fun getXml(id: Int): XmlResourceParser

Deprecated: Deprecated in Java.

Parameters
id Int: The desired resource identifier, as generated by the aapt tool. This integer encodes the package, type, and resource entry. The value 0 is an invalid identifier.
Return
XmlResourceParser A new parser object through which you can read the XML data. This value cannot be null.
Exceptions
android.content.res.Resources.NotFoundException Throws NotFoundException if the given ID does not exist.

obtainAttributes

Added in API level 1
open fun obtainAttributes(
    set: AttributeSet!,
    attrs: IntArray!
): TypedArray!

Deprecated: Deprecated in Java.

Parameters
set AttributeSet!: The current attribute values to retrieve.
attrs IntArray!: The specific attributes to be retrieved. These attribute IDs must be sorted in ascending order.
Return
TypedArray! Returns a TypedArray holding an array of the attribute values. Be sure to call TypedArray.recycle() when done with it.

obtainTypedArray

Added in API level 1
open fun obtainTypedArray(id: Int): TypedArray

Deprecated: Deprecated in Java.

Parameters
id Int: The desired resource identifier, as generated by the aapt tool. This integer encodes the package, type, and resource entry. The value 0 is an invalid identifier.
Return
TypedArray Returns a TypedArray holding an array of the array values. Be sure to call TypedArray.recycle() when done with it. This value cannot be null.
Exceptions
android.content.res.Resources.NotFoundException Throws NotFoundException if the given ID does not exist.

openRawResource

Added in API level 1
open fun openRawResource(id: Int): InputStream

Deprecated: Deprecated in Java.

Parameters
id Int: The resource identifier to open, as generated by the aapt tool.
Return
InputStream InputStream Access to the resource data. This value cannot be null.
Exceptions
android.content.res.Resources.NotFoundException Throws NotFoundException if the given ID does not exist.

openRawResourceFd

Added in API level 1
open fun openRawResourceFd(id: Int): AssetFileDescriptor!

Deprecated: Deprecated in Java.

Parameters
id Int: The resource identifier to open, as generated by the aapt tool.
Return
AssetFileDescriptor! AssetFileDescriptor A new file descriptor you can use to read the resource. This includes the file descriptor itself, as well as the offset and length of data where the resource appears in the file. A null is returned if the file exists but is compressed.
Exceptions
android.content.res.Resources.NotFoundException Throws NotFoundException if the given ID does not exist.

updateConfiguration

Added in API level 1
open fun updateConfiguration(
    config: Configuration!,
    metrics: DisplayMetrics!
): Unit

Deprecated: Deprecated in Java.