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
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)
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"));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.