将数据从arduino发送到菜单SearchView

时间:2018-05-08 06:27:46

标签: android arduino-uno

我尝试用arduino读取id rfid,然后id rfid将发送到android studio并在SearchView中显示,但我无法向SearchView显示id。这是我的编码

SuppressLint("HandlerLeak")
Handler mHandler = new Handler() {
    @Override
    public void handleMessage(Message msg) {
        // TODO Auto-generated method stub
        super.handleMessage(msg);
        switch (msg.what) {
            case bluet.SUCCESS_CONNECT:
                bluet.connectedThread = new bluet.ConnectedThread((BluetoothSocket) msg.obj);
                Toast.makeText(getApplicationContext(), "Connected!", Toast.LENGTH_SHORT).show();
                bluet.connectedThread.start();
                break;
            case bluet.MESSAGE_READ:
                byte[] readBuf = (byte[]) msg.obj;
                String strIncom = new String(readBuf);
                strIncom = strIncom.trim();
                try{searchView.setQuery(strIncom,true);}catch (Exception e){Log.e("ga",strIncom);}
        }
    }

};

0 个答案:

没有答案