-1
나는 블루투스를 통해 바이너리 형식으로 바이트를 보내는 방법을 알고 싶었습니다. 순간 나는이 코드를 사용합니다에만이 방법으로블루투스를 통해 바이트 보내기
mSendButton = (Button) findViewById(R.id.button_send);
mSendButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// Send a message using content of the edit text widget
TextView view = (TextView) findViewById(R.id.edit_text_out);
String message = view.getText().toString();
sendMessage(message);
}
});
를 바이트 문자열과하지를 보냅니다.
도움 주셔서 감사합니다. 소스 코드에 따르면
이private void sendMessage(String message) {
// Check that we're actually connected before trying anything
if (mChatService.getState() != BluetoothChatService.STATE_CONNECTED) {
Toast.makeText(this, R.string.not_connected, Toast.LENGTH_SHORT).show();
return;
}
// Check that there's actually something to send
if (message.length() > 0) {
// Get the message bytes and tell the BluetoothChatService to write
byte[] send = message.getBytes();
mChatService.write(send);
// Reset out string buffer to zero and clear the edit text field
mOutStringBuffer.setLength(0);
mOutEditText.setText(mOutStringBuffer);
}
}
'sendMessage' 메소드의 소스는 무엇입니까? –
@ Juan-devtopia.coop 여기에 소스가 있습니다 – davix10