Example usage for android.os IBinder unlinkToDeath

List of usage examples for android.os IBinder unlinkToDeath

Introduction

In this page you can find the example usage for android.os IBinder unlinkToDeath.

Prototype

public boolean unlinkToDeath(@NonNull DeathRecipient recipient, int flags);

Source Link

Document

Remove a previously registered death notification.

Usage

From source file:com.ferdi2005.secondgram.support.customtabs.CustomTabsService.java

protected boolean cleanUpSession(CustomTabsSessionToken sessionToken) {
    try {/*w w  w. jav  a2  s. com*/
        Map e = this.mDeathRecipientMap;
        synchronized (this.mDeathRecipientMap) {
            IBinder binder = sessionToken.getCallbackBinder();
            DeathRecipient deathRecipient = this.mDeathRecipientMap.get(binder);
            binder.unlinkToDeath(deathRecipient, 0);
            this.mDeathRecipientMap.remove(binder);
            return true;
        }
    } catch (NoSuchElementException var7) {
        return false;
    }
}

From source file:android.support.customtabs.CustomTabsService.java

/**
 * Called when the client side {@link IBinder} for this {@link CustomTabsSessionToken} is dead.
 * Can also be used to clean up {@link DeathRecipient} instances allocated for the given token.
 * @param sessionToken The session token for which the {@link DeathRecipient} call has been
 *                     received./*from  w ww .  j  a va  2 s. c om*/
 * @return Whether the clean up was successful. Multiple calls with two tokens holdings the
 *         same binder will return false.
 */
protected boolean cleanUpSession(CustomTabsSessionToken sessionToken) {
    try {
        synchronized (mDeathRecipientMap) {
            IBinder binder = sessionToken.getCallbackBinder();
            DeathRecipient deathRecipient = mDeathRecipientMap.get(binder);
            binder.unlinkToDeath(deathRecipient, 0);
            mDeathRecipientMap.remove(binder);
        }
    } catch (NoSuchElementException e) {
        return false;
    }
    return true;
}