0

我正在关注一个关于 Android 中蓝牙的示例。当按照示例并尝试理解该过程时,我收到一个错误:“返回类型与 Thread.getState() 不兼容”。是什么导致此错误,我该如何解决?

以下是相关代码:

private int mState;
  /**
   * Set the current state of the chat connection
   * @param state  An integer defining the current connection state
   */
  private synchronized void setState(int state) {
      if (D) Log.d(TAG, "setState() " + mState + " -> " + state);
      mState = state;

      // Give the new state to the Handler so the UI Activity can update
      mHandler.obtainMessage(Rc_auto.MESSAGE_STATE_CHANGE, state, -1).sendToTarget();
  }

  /**
   * Return the current connection state. */
  public synchronized int getState() {
      return mState;
  }

  //How it's called
  public synchronized void start() {
      setState(STATE_LISTEN);
  }
4

2 回答 2

3

您可能应该重命名getState()为其他名称(例如 getConnectionState),因为您的方法会覆盖Thread.getState(),我猜这不是您想要的。

于 2013-04-26T15:01:41.030 回答
0

答案在我的问题下方的评论中给出。

我只需要在课程开始时删除“扩展线程”。

你们所有人的帮助都很有帮助,我学到了一些额外的东西。

感谢大家

于 2013-04-28T07:53:45.923 回答