예제 #1
0
  /**
   * Send message back to handler which is initialized in a activity
   *
   * @param what Message integer you want to send
   */
  private void sendMessageToHandler(Integer what) {
    Message msg = Message.obtain();
    msg.what = what;

    try {
      mMessenger.send(msg);
    } catch (RemoteException e) {
      Log.w(Constants.TAG, "Exception sending message, Is handler present?", e);
    } catch (NullPointerException e) {
      Log.w(Constants.TAG, "Messenger is null!", e);
    }
  }
예제 #2
0
  private void sendMessageToHandler(Integer arg1, Integer arg2, Bundle data) {
    // Service was canceled. Do not send message to handler.
    if (this.mIsCanceled) {
      return;
    }

    Message msg = Message.obtain();
    msg.arg1 = arg1;
    if (arg2 != null) {
      msg.arg2 = arg2;
    }
    if (data != null) {
      msg.setData(data);
    }

    try {
      mMessenger.send(msg);
    } catch (RemoteException e) {
      Log.w(Constants.TAG, "Exception sending message, Is handler present?", e);
    } catch (NullPointerException e) {
      Log.w(Constants.TAG, "Messenger is null!", e);
    }
  }