1

I'm trying to send an image via bluetooth, i keep getting an error saying Unable to create content to send

The code is as follows:

public void onClick(View v) {
    Intent i = new Intent(Intent.ACTION_SEND);
    i.setType("image/jpeg");     
    i.putExtra(Intent.EXTRA_STREAM, Uri.parse("/sdcard/test.jpeg"));  
    startActivity(Intent.createChooser(i, "Send Image")); // TODO Auto-generated method stub
}

Many Thanks

Caner
  • 57,267
  • 35
  • 174
  • 180
user1314243
  • 639
  • 1
  • 5
  • 7

2 Answers2

0

I think the path to the image is incorrect, try this:

i.putExtra(Intent.EXTRA_STREAM, Uri.parse(Environment.getExternalStorageDirectory() + "/test.jpeg"));

Also here is an example on how to send file over bluetooth:

Sending a File using Bluetooth OBEX Object Push Profile (OPP)

Community
  • 1
  • 1
Caner
  • 57,267
  • 35
  • 174
  • 180
0

if you want to use a file as uri you need to add file://

Uri.parse("file:///sdcard/test.jpeg")

or

Uri.fromFile(new File("/sdcard/test.jpg"));
zapl
  • 63,179
  • 10
  • 123
  • 154