Androidで2台のデバイス間でBluetooth経由のファイル転送をうまく行った.デフォルトではBluetoothの受信フォルダに受信された.ファイルの受信場所を変更することは可能ですか? 例のために。両方のデバイス (D1 と D2) に独自のアプリケーションをインストールしました。D1 のアプリから D2 にファイルを送信します。このファイルを D2 の自分のアプリで直接受信して開くことは可能ですか? もしそうなら、どうすればいいですか?
私のコード:
sendDirectly.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (btAdapter.isEnabled()) {
Set<BluetoothDevice> devices = btAdapter.getBondedDevices();
if (devices.size() > 0) {
for ( BluetoothDevice device : devices) {
deviceBTAddress=device.getAddress();
}
ContentValues values = new ContentValues();
// values.put(BluetoothShare.URI, Uri.fromFile(new
// File(uri.getPath())).toString());
values.put(BluetoothShare.URI, uri.toString());
values.put(BluetoothShare.MIMETYPE, "image/jpeg");
values.put(BluetoothShare.DESTINATION, deviceBTAddress);
values.put(BluetoothShare.DIRECTION,
BluetoothShare.DIRECTION_OUTBOUND);
Long ts = System.currentTimeMillis();
values.put(BluetoothShare.TIMESTAMP, ts);
final Uri contentUri = getApplicationContext().getContentResolver()
.insert(BluetoothShare.CONTENT_URI, values);
}
}
}
}