需要帮助在我的Android应用中实施蓝牙

时间:2018-03-14 19:50:30

标签: android bluetooth

我正在为arduino温度计创建一个应用程序,通过蓝牙连接。 但是我发现很难在Android工作室中实现蓝牙我看了例here,我在实现它时遇到了错误。

“MyBluetoothService”类中的第65行正在创建错误。

错误是:无法解析方法“obtainMessage(int,int,int,byte [])

指向完整code

的链接

这里有错误的代码:

        public void run() {

             mmBuffer = new byte[1024];

             int numBytes; // bytes returned from read()

            // Keep listening to the InputStream until an exception occurs.
            while (true) {
                try {
                    // Read from the InputStream.
                    numBytes = mmInStream.read(mmBuffer);
                    // Send the obtained bytes to the UI activity.
                    Message readMsg = mHandler.obtainMessage(
                            MessageConstants.MESSAGE_READ, numBytes, -1,
                            mmBuffer);
                    readMsg.sendToTarget();
                } catch (IOException e) {
                    Log.d(TAG, "Input stream was disconnected", e);
                    break;
                }
            }
        }

0 个答案:

没有答案