【问题标题】:android bluetooth file transfer failure安卓蓝牙文件传输失败
【发布时间】: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


【解决方案1】:

您可能需要查看this library 以使用蓝牙在 Android 设备之间发送文件和其他数据(免责声明:我是作者)

【讨论】:

    猜你喜欢
    • 2011-08-13
    • 2012-04-02
    • 1970-01-01
    • 1970-01-01
    • 2013-11-10
    • 1970-01-01
    • 2012-07-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多