Build 1.0_r1(from source)

Class TokenWatcher

  extended by android.os.TokenWatcher

public abstract class TokenWatcher
extends Object

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

Constructor Summary
TokenWatcher(Handler h, String tag)
          Construct the TokenWatcher
Method Summary
 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()
 boolean isAcquired()
 void release(IBinder token)
abstract  void released()
          Called when the number of active tokens goes from 1 to 0.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail


public TokenWatcher(Handler h,
                    String tag)
Construct the TokenWatcher

h - 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 - A debugging tag for this TokenWatcher
Method Detail


public abstract void acquired()
Called when the number of active tokens goes from 0 to 1.


public abstract void released()
Called when the number of active tokens goes from 1 to 0.


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.

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


public void cleanup(IBinder token,
                    boolean unlink)


public void release(IBinder token)


public boolean isAcquired()


public void dump()

Build 1.0_r1(from source)

Please submit a feedback, bug or feature