【发布时间】:2015-11-24 08:19:09
【问题描述】:
我正在尝试通过蓝牙发送文件,但它没有发送任何数据。 这里的主要问题是它没有通过两个设备发送或接收任何数据,但它们相互连接。
发送代码:
File myFile = new File(message.toURI());
Double nosofpackets = Math.ceil(((int) myFile.length() )/4096);
System.out.println(nosofpackets);
BufferedInputStream bis = new BufferedInputStream(new FileInputStream(myFile));
byte[] send = new byte[4096];
for(double i = 0; i < nosofpackets; i++)
{
send = null ;
a=bis.read(send, 0, send.length);
Log.d("BluetoothChat", "data packet " + i);
if(a == -1)
{
break;
}
mChatService.write(send);
}
接收代码:
while((bytes = mmInStream.read(buffer)) > 0)
{
Log.d(TAG, "data is there for writing");
bos.write(buffer);
}
【问题讨论】:
-
@Anu 是否可以使用该代码一次发送多个用户的意图设置.. 我的意思是说假设我试图将同一个文件发送到 4 个或更多配对设备go..这可能吗..?
标签: java android file-transfer android-networking rfcomm