Android APIs
public abstract class

TokenWatcher

extends Object
java.lang.Object
   ↳ android.os.TokenWatcher

Class Overview

Helper class that helps you use IBinder objects as reference counted tokens. IBinders make good tokens because we find out when they are removed

Summary

Public Constructors
TokenWatcher(Handler h, String tag)
Construct the TokenWatcher
Public Methods
void acquire(IBinder token, String tag)
Record that this token has been acquired.
abstract void acquired()
Called when the number of active tokens goes from 0 to 1.
void cleanup(IBinder token, boolean unlink)
void dump()
void dump(PrintWriter pw)
boolean isAcquired()
void release(IBinder token)
abstract void released()
Called when the number of active tokens goes from 1 to 0.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public TokenWatcher (Handler h, String tag)

Added in API level 1

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

public void acquire (IBinder token, String tag)

Added in API level 1

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.

Parameters
token IBinder: An IBinder object. If this token has already been acquired, no action is taken.
tag String: A string used by the dump() method for debugging, to see who has references.

public abstract void acquired ()

Added in API level 1

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

public void cleanup (IBinder token, boolean unlink)

Added in API level 1

Parameters
token IBinder
unlink boolean

public void dump ()

Added in API level 1

public void dump (PrintWriter pw)

Added in API level 16

Parameters
pw PrintWriter

public boolean isAcquired ()

Added in API level 1

Returns
boolean

public void release (IBinder token)

Added in API level 1

Parameters
token IBinder

public abstract void released ()

Added in API level 1

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