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
  • 53,818
  • 35
  • 164
  • 173
user1314243
  • 569
  • 1
  • 4
  • 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
  • 53,818
  • 35
  • 164
  • 173
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
  • 61,739
  • 10
  • 119
  • 146