Bluetooth file transfer Android

≯℡__Kan透↙ 提交于 2019-11-27 18:25:59

I was able to solve this problem by sending small chunks of data out to the bluetooth outstream. It turned out that 8 * 1024 was a good buffer size, which helped in sending out data seamlessly over the stream as well as preventing corruption of data at the receiving end.

BufferedInputStream bis = new BufferedInputStream(fis, 8 * 1024);


byte[] buffer = new byte[8192];
int len
while ((len = bis.read(buffer)) != -1) {
    outStream.write(buffer, 0, len);
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!