Code example for Handler

Methods: sendEmptyMessageDelayed

    private synchronized void releaseCamera() { 
        Assert(mUsers == 0);
        Assert(mCameraDevice != null);
        long now = System.currentTimeMillis();
        if (now < mKeepBeforeTime) {
                    mKeepBeforeTime - now);
        mCameraDevice = null;
        // We must set this to null because it has a reference to Camera. 
        // Camera has references to the listeners. 
        mParameters = null;
        mCameraId = -1;
    public synchronized void keep() { 
        // We allow (mUsers == 0) for the convenience of the calling activity. 
        // The activity may not have a chance to call open() before the user 
Connect your IDE to all the code out there  Get Codota for Java