1

How to send a image file from one device to another using bluetooth in Android programmatically. I Can send text files correctly,but when trying to send image files it shows error.

Sample code is here:

ContentValues values = new ContentValues();

  values.put(BluetoothShare.URI, url);

  values.put(BluetoothShare.DESTINATION, deviceAddress);

  values.put(BluetoothShare.DIRECTION, BluetoothShare.DIRECTION_OUTBOUND);

  Long ts = System.currentTimeMillis();

  values.put(BluetoothShare.TIMESTAMP, ts);

  getContentResolver().insert(BluetoothShare.CONTENT_URI, values);

Here url refers to the path of the image.

4

1 に答える 1

3

you can use this code for this problem :

 File file=new File(imagePath);
 Uri uri=Uri.fromFile(file);

 ContentValues values = new ContentValues();

  values.put(BluetoothShare.URI, uri.toString());

  values.put(BluetoothShare.DESTINATION, deviceAddress);

  values.put(BluetoothShare.DIRECTION, BluetoothShare.DIRECTION_OUTBOUND);

  Long ts = System.currentTimeMillis();

  values.put(BluetoothShare.TIMESTAMP, ts);

  getContentResolver().insert(BluetoothShare.CONTENT_URI, values);
于 2012-10-09T03:48:54.040 に答える