Added in API level 1

TokenWatcher

abstract class TokenWatcher
kotlin.Any
   ↳ android.os.TokenWatcher

A TokenWatcher watches a collection of IBinders. IBinders are added to the collection by calling acquire, and removed by calling release. IBinders are also implicitly removed when they become weakly reachable. Each IBinder may be added at most once. The acquired method is invoked by posting to the specified handler whenever the size of the watched collection becomes nonzero. The released method is invoked on the specified handler whenever the size of the watched collection becomes zero.

Summary

Public constructors

Construct the TokenWatcher

Public methods
open Unit
acquire(token: IBinder!, tag: String!)

Record that this token has been acquired.

abstract Unit

Called when the number of active tokens goes from 0 to 1.

open Unit
cleanup(token: IBinder!, unlink: Boolean)

open Unit

open Unit

open Boolean

open Unit
release(token: IBinder!)

abstract Unit

Called when the number of active tokens goes from 1 to 0.

Public constructors

TokenWatcher

Added in API level 1
TokenWatcher(
    h: Handler!,
    tag: String!)

Construct the TokenWatcher

Parameters
h Handler!: A handler to call acquired and released on. If you don't care, just call it like this, although your thread will have to be a Looper thread. new TokenWatcher(new Handler())
tag String!: A debugging tag for this TokenWatcher

Public methods

acquire

Added in API level 1
open fun acquire(
    token: IBinder!,
    tag: String!
): Unit

Record that this token has been acquired. When acquire is called, and the current count is 0, the acquired method is called on the given handler. Note that the same token can only be acquired once. If this token has already been acquired, no action is taken. The first subsequent call to release will release this token immediately.

Parameters
token IBinder!: An IBinder object.
tag String!: A string used by the #dump method for debugging, to see who has references.

acquired

Added in API level 1
abstract fun acquired(): Unit

Called when the number of active tokens goes from 0 to 1.

cleanup

Added in API level 1
open fun cleanup(
    token: IBinder!,
    unlink: Boolean
): Unit

dump

Added in API level 1
open fun dump(): Unit

dump

Added in API level 16
open fun dump(pw: PrintWriter!): Unit

isAcquired

Added in API level 1
open fun isAcquired(): Boolean

release

Added in API level 1
open fun release(token: IBinder!): Unit

released

Added in API level 1
abstract fun released(): Unit

Called when the number of active tokens goes from 1 to 0.