我想将文件发送到蓝牙设备列表;我明白了:
private void envio_brodcast() {
String mdeviceadd="";
File myFile = new File(_path);
//BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
if(mBluetoothAdapter == null)
{
}
if(!mBluetoothAdapter.isEnabled())
{
Intent enableBluetooth = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(enableBluetooth, 0);
}
mBluetoothAdapter.startDiscovery();
mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
Set<BluetoothDevice> pairedDevices = mBluetoothAdapter.getBondedDevices();
if(pairedDevices.size() > 0)
{
for(BluetoothDevice device : pairedDevices)
{
if(device.getName()!=null)
{
String nombreDispocitivo=device.getName();
Toast.makeText(this,nombreDispocitivo,Toast.LENGTH_LONG).show();
BluetoothDevice mmDevice = device;
mdeviceadd = device.getAddress();
Toast.makeText(this,nombreDispocitivo,Toast.LENGTH_LONG).show();
ContentValues values = new ContentValues();
values.put(BluetoothShare.URI,_path);
values.put(BluetoothShare.DESTINATION, mdeviceadd);
values.put(BluetoothShare.DIRECTION, BluetoothShare.DIRECTION_OUTBOUND);
Long ts = System.currentTimeMillis();
values.put(BluetoothShare.TIMESTAMP, ts);
getContentResolver().insert(BluetoothShare.CONTENT_URI, values);
}
}
}
}
这没用。如果有人可以向我发送代码以将文件发送到具有此结构的特定 dispocitivo:
public void send_file(BluetoothDevice mmDevice,Uri outputFileUri)
我会很感激。