@Override
 public void onDestroy() {
   super.onDestroy();
   mHandler.removeCallbacks(mUpdateDisplay);
   cleanUp();
   Log.d(TAG, ".onDestroy()");
 }
    void detach() {
      if (mDestroyed) {
        return;
      }

      mDestroyed = true;

      if (mVisible) {
        mVisible = false;
        if (DEBUG) Log.v(TAG, "onVisibilityChanged(false): " + this);
        onVisibilityChanged(false);
      }

      reportSurfaceDestroyed();

      if (DEBUG) Log.v(TAG, "onDestroy(): " + this);
      onDestroy();

      unregisterReceiver(mReceiver);

      if (mCreated) {
        try {
          if (DEBUG)
            Log.v(
                TAG,
                "Removing window and destroying surface "
                    + mSurfaceHolder.getSurface()
                    + " of: "
                    + this);

          if (mInputEventReceiver != null) {
            mInputEventReceiver.dispose();
            mInputEventReceiver = null;
          }

          mSession.remove(mWindow);
        } catch (RemoteException e) {
        }
        mSurfaceHolder.mSurface.release();
        mCreated = false;

        // Dispose the input channel after removing the window so the Window Manager
        // doesn't interpret the input channel being closed as an abnormal termination.
        if (mInputChannel != null) {
          mInputChannel.dispose();
          mInputChannel = null;
        }
      }
    }
 @Override
 public void onDestroy() {
   super.onDestroy();
   handler.removeCallbacks(timerRefresh);
   handler.removeCallbacks(timerGetImages);
 }