Android デバイスで Bluetooth 経由でファイルを送信しようとしています。発見、接続を行い、Bluetoothソケットを作成しました。問題は、Bluetoothソケットの出力ストリームにバイト配列を書き込んでいるときに、何かが送信されていることを受け入れても、受信側は何も受信しないことです。
これが私がやっていることです(悪いのはBluetoothアダプターです)
お知らせ下さい。
try
{
BluetoothDevice dev = bad.getRemoteDevice(a);
bad.cancelDiscovery();
dev.createRfcommSocketToServiceRecord(new UUID(1111, 2222));
Method m = dev.getClass().getMethod("createRfcommSocket", new Class[] {int.class});
bs = (BluetoothSocket) m.invoke(dev, Integer.valueOf(1));
bs.connect();
tmpOut = bs.getOutputStream();
}catch(Exception e)
{
}
File f = new File(filename);
byte b[] = new byte[(int) f.length()];
try
{
FileInputStream fileInputStream = new FileInputStream(f);
fileInputStream.read(b);
}catch(IOException e)
{
Log.d(TAG, "Error converting file");
Log.d(TAG, e.getMessage());
}
try {
tmpOut.write(b);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}