簡體   English   中英

如何在Android中顯示數據緩沖區?

[英]How to display data buffer in android?

我是android開發應用程序中的新手。想從藍牙套接字的Buffer中讀取數據並顯示它。 數據來自溫度傳感器(LM35>微控制器>藍牙模塊> android設備)。 下面是編碼讀取並將數據保存到buffer.i我想知道,如何顯示它的編碼。 希望你們能幫助我。 非常感謝你..

         byte[] buffer = new byte[1024];
         int bytes;
         try {
              InputStream instream = Bee_btSocket.getInputStream();
              bytes = instream.read(buffer);
             }

         catch (IOException e) {
         break;

我通過以下代碼來做這件事...

 public ConnectedThread(BluetoothSocket socket) { Log.d(TAG, "create ConnectedThread"); mmSocket = socket; InputStream tmpIn = null; OutputStream tmpOut = null; // Get the BluetoothSocket input and output streams try { tmpIn = socket.getInputStream(); tmpOut = socket.getOutputStream(); } catch (IOException e) { Log.e(TAG, "temp sockets not created", e); } mmInStream = tmpIn; mmOutStream = tmpOut; } public void run() { Log.i(TAG, "BEGIN mConnectedThread"); byte[] buffer = new byte[1024]; int bytes; // Keep listening to the InputStream while connected while (true) { try { // Read from the InputStream bytes = mmInStream.read(buffer); // Send the obtained bytes to the UI Activity mHandler.obtainMessage(BluetoothChat.MESSAGE_READ, bytes, -1, buffer) .sendToTarget(); } catch (IOException e) { Log.e(TAG, "disconnected", e); connectionLost(); break; } } } 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM