# Print output for @column tags ?>
Developers

- Design
- Develop
- Distribute

Developer Console

## Most visited

## Recently visited

## Results for

Summary: Ctors | Methods | Inherited Methods

# TokenWatcher

`public abstract class TokenWatcher`
`extends Object` ``

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

A TokenWatcher watches a collection of `IBinder`s. IBinders are added to the collection by calling `acquire(IBinder, String)`, and removed by calling `release(IBinder)`. 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
`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(PrintWriter pw)`
`void` | `dump()`
`boolean` | `isAcquired()`
`void` | `release(IBinder token)`
`abstract void` | `released()` Called when the number of active tokens goes from 1 to 0.

### Inherited methods
From class `java.lang.Object`
`Object` | `clone()` Creates and returns a copy of this object.
`boolean` | `equals(Object obj)` Indicates whether some other object is "equal to" this one.
`void` | `finalize()` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
`final Class<?>` | `getClass()` Returns the runtime class of this `Object`.
`int` | `hashCode()` Returns a hash code value for the object.
`final void` | `notify()` Wakes up a single thread that is waiting on this object's monitor.
`final void` | `notifyAll()` Wakes up all threads that are waiting on this object's monitor.
`String` | `toString()` Returns a string representation of the object.
`final void` | `wait(long timeout, int nanos)` Causes the current thread to wait until another thread invokes the `notify()` method or the `notifyAll()` method for this object, or some other thread interrupts the current thread, or a certain amount of real time has elapsed.
`final void` | `wait(long timeout)` Causes the current thread to wait until either another thread invokes the `notify()` method or the `notifyAll()` method for this object, or a specified amount of time has elapsed.
`final void` | `wait()` Causes the current thread to wait until another thread invokes the `notify()` method or the `notifyAll()` method for this object.

## Public constructors

### TokenWatcher

    public TokenWatcher (Handler h,
                    String tag)

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

    public void acquire (IBinder token,
                    String tag)

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(IBinder)` 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

    public abstract void acquired ()

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

### cleanup

    public void cleanup (IBinder token,
                    boolean unlink)

Parameters
`token` | `IBinder`
`unlink` | `boolean`

### dump

    public void dump (PrintWriter pw)

Parameters
`pw` | `PrintWriter`

### dump

    public void dump ()

### isAcquired

    public boolean isAcquired ()

Returns
`boolean` |

### release

    public void release (IBinder token)

Parameters
`token` | `IBinder`

### released

    public abstract void released ()

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

Full name *
Email address *
Company / developer name
One of your Play Store app URLs *
Which best describes your business:*
Apps
Games
Apps & Games
*
*