コード例 #1
0
  private void disconnectFromRemoteDocument() {
    try {
      mPrintDocumentAdapter.setObserver(null);
    } catch (RemoteException re) {
      Log.w(LOG_TAG, "Error setting observer to the print adapter.");
      // Keep going - best effort...
    }

    mPrintDocumentAdapter.asBinder().unlinkToDeath(mDeathRecipient, 0);
  }
コード例 #2
0
  private void connectToRemoteDocument() {
    try {
      mPrintDocumentAdapter.asBinder().linkToDeath(mDeathRecipient, 0);
    } catch (RemoteException re) {
      Log.w(LOG_TAG, "The printing process is dead.");
      destroy();
      return;
    }

    try {
      mPrintDocumentAdapter.setObserver(new PrintDocumentAdapterObserver(this));
    } catch (RemoteException re) {
      Log.w(LOG_TAG, "Error setting observer to the print adapter.");
      destroy();
    }
  }
コード例 #3
0
  public void kill(String reason) {
    if (DEBUG) {
      Log.i(LOG_TAG, "[CALLED] kill()");
    }

    try {
      mPrintDocumentAdapter.kill(reason);
    } catch (RemoteException re) {
      Log.e(LOG_TAG, "Error calling kill()", re);
    }
  }
コード例 #4
0
 public void finish() {
   if (DEBUG) {
     Log.i(LOG_TAG, "[CALLED] finish()");
   }
   if (mState != STATE_STARTED
       && mState != STATE_UPDATED
       && mState != STATE_FAILED
       && mState != STATE_CANCELING
       && mState != STATE_CANCELED
       && mState != STATE_DESTROYED) {
     throw new IllegalStateException("Cannot finish in state:" + stateToString(mState));
   }
   try {
     mPrintDocumentAdapter.finish();
     mState = STATE_FINISHED;
   } catch (RemoteException re) {
     Log.e(LOG_TAG, "Error calling finish()");
     mState = STATE_FAILED;
   }
 }
コード例 #5
0
 public void start() {
   if (DEBUG) {
     Log.i(LOG_TAG, "[CALLED] start()");
   }
   if (mState == STATE_FAILED) {
     Log.w(LOG_TAG, "Failed before start.");
   } else if (mState == STATE_DESTROYED) {
     Log.w(LOG_TAG, "Destroyed before start.");
   } else {
     if (mState != STATE_INITIAL) {
       throw new IllegalStateException("Cannot start in state:" + stateToString(mState));
     }
     try {
       mPrintDocumentAdapter.start();
       mState = STATE_STARTED;
     } catch (RemoteException re) {
       Log.e(LOG_TAG, "Error calling start()", re);
       mState = STATE_FAILED;
     }
   }
 }