Example usage for android.content ServiceConnection onServiceDisconnected

List of usage examples for android.content ServiceConnection onServiceDisconnected

Introduction

In this page you can find the example usage for android.content ServiceConnection onServiceDisconnected.

Prototype

void onServiceDisconnected(ComponentName name);

Source Link

Document

Called when a connection to the Service has been lost.

Usage

From source file:edu.umich.flowfence.sandbox.SandboxContext.java

@Override
public void unbindService(ServiceConnection conn) {
    synchronized (mBoundServices) {
        ComponentName removed = mBoundServices.remove(conn);
        if (removed != null) {
            conn.onServiceDisconnected(removed);
            return;
        }// ww w. j  a va2s .  c o m
    }
    super.unbindService(conn);
}

From source file:android.content.ScopedContextImpl.java

@Override
public void unbindService(ServiceConnection conn) {

    ImmortalMemory.instance().executeInArea(new Runnable() {

        public void run() {
            try {
                String bindingComponent = name.getClassName();
                Set<String> set = intentReslover.removeBindingRecord(bindingComponent);
                for (String item : set) {
                    int count = intentReslover.getBindingRecord(item);
                    if (count == 1) {
                        intentReslover.removeBindingRecord(item);
                        stopService(null, item);
                    } else {
                        intentReslover.updateBindingRecord(item, count - 1);
                    }/*from   w w w .  j a v  a 2 s  . c  o m*/
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });

    conn.onServiceDisconnected(null);
}