byte는 0-255 되어야 하는건 당연한 것입니다
이게 안된다면 이미지(byte array)를 어떻게 보내며 파일을 어떻게 보내겠습니까
단지 그것을 화면에 출력할때에 signed 로 보여서 문제일것인데
아래처럼 해결을 해보세요
int i = 200;
byte b = (byte)200;
// Will print a negative value but you could *still choose to interpret* this as +200.
System.err.println(b);
// "Upcast" to short in order to easily view / interpret as a positive value.
// You would typically do this *within* the method that expected an unsigned byte.
short s = b & 0xFF;
System.err.println(s); // Will print a positive value.
다음은 송수신 방법 입니다
void sendFile(Uri uri, BluetoothSocket bs) throws IOException
{
try
{
BufferedInputStream bis = new BufferedInputStream(getContentResolver().openInputStream(uri));
OutputStream os = bs.getOutputStream();
int bufferSize = 1024;
byte[] buffer = new byte[bufferSize];
// we need to know how may bytes were read to write them to the byteBuffer
int len = 0;
while ((len = inputStream.read(buffer)) != -1)
{
os.write(buffer, 0, len);
}
}
finally
{
if(bis != null)
bis.close();
}
}
블루투스를 이용하여 바이트 통신은 아주 쉽게 0-255(1바이트당) 까지 보낼수 있습니다
doridori2013@nate.com