Save the date! Android Dev Summit is coming to Mountain View, CA on November 7-8, 2018.

androidx.core.os

Classes

BuildCompat

This class contains additional platform version checking methods for targeting pre-release versions of Android.

CancellationSignal

Static library support version of the framework's android.os.CancellationSignal.

ConfigurationCompat

Helper class which allows access to properties of Configuration in a backward compatible fashion.

EnvironmentCompat

Helper for accessing features in Environment.

HandlerCompat

Helper for accessing features in Handler.

LocaleListCompat

Helper for accessing features in LocaleList.

ParcelableCompat

Helper for accessing features in android.os.Parcelable.

ParcelCompat

Helper for accessing features in Parcel.

TraceCompat

Writes trace events to the system trace buffer.

UserManagerCompat

Helper for accessing features in android.os.UserManager in a backwards compatible fashion.

Exceptions

OperationCanceledException

An exception type that is thrown when an operation in progress is canceled.

Top-level functions summary

Bundle
bundleOf(vararg pairs: Pair<String, Any?>)

Returns a new Bundle with the given key/value pairs as elements.

PersistableBundle
persistableBundleOf(vararg pairs: Pair<String, Any?>)

Returns a new PersistableBundle with the given key/value pairs as elements.

T
trace(sectionName: String, block: () -> T)

Wrap the specified block in calls to Trace.beginSection (with the supplied sectionName) and Trace.endSection.

Extension functions summary

For android.os.Handler
Runnable
Handler.postDelayed(delayInMillis: Long, token: Any? = null, crossinline action: () -> Unit)

Version of Handler.postDelayed which re-orders the parameters, allowing the action to be placed outside of parentheses.

Runnable
Handler.postAtTime(uptimeMillis: Long, token: Any? = null, crossinline action: () -> Unit)

Version of Handler.postAtTime which re-orders the parameters, allowing the action to be placed outside of parentheses.

Top-level functions

bundleOf

fun bundleOf(vararg pairs: Pair<String, Any?>): Bundle

Returns a new Bundle with the given key/value pairs as elements.

Exceptions
IllegalArgumentException When a value is not a supported type of Bundle.

persistableBundleOf

fun persistableBundleOf(vararg pairs: Pair<String, Any?>): PersistableBundle

Returns a new PersistableBundle with the given key/value pairs as elements.

Exceptions
IllegalArgumentException When a value is not a supported type of PersistableBundle.

trace

inline fun <T> trace(sectionName: String, block: () -> T): T

Wrap the specified block in calls to Trace.beginSection (with the supplied sectionName) and Trace.endSection.

Extension functions

postAtTime

inline fun Handler.postAtTime(uptimeMillis: Long, token: Any? = null, crossinline action: () -> Unit): Runnable

Version of Handler.postAtTime which re-orders the parameters, allowing the action to be placed outside of parentheses.


handler.postAtTime(200) {
    doSomething()
}
Parameters
token An optional object with which the posted message will be associated.
Return
the created Runnable

postDelayed

inline fun Handler.postDelayed(delayInMillis: Long, token: Any? = null, crossinline action: () -> Unit): Runnable

Version of Handler.postDelayed which re-orders the parameters, allowing the action to be placed outside of parentheses.


handler.postDelayed(200) {
    doSomething()
}
Return
the created Runnable