Hello I am trying to send photo with this code which seems to be run on whatsApp properly but whenever I use it with android native messaging app it says "Attaching image failed;file not supported"
After capturing image from camera I am able to save it successfully in the external storage with this line of code:
private File createImageFile() throws IOException {
String imageFileName = "imagex";
File storageDir = Environment.getExternalStoragePublicDirectory(
Environment.DIRECTORY_PICTURES);
File image = File.createTempFile(
imageFileName, /* prefix */
".jpg", /* suffix */
storageDir /* directory */
);
mCurrentPhotoPath = image.getAbsolutePath();
return image;
}
In mcurrentPath I saved the path to the image file and then I used this as uri in the code below to send mms:
private void sendme() {
String imageFileName = "imagex.jpg";
//File storageDir = Environment.getExternalStoragePublicDirectory(
// Environment.DIRECTORY_PICTURES);
//File image =new File(storageDir,imageFileName);
String path=mCurrentPhotoPath;
Intent i = new Intent(Intent.ACTION_SEND);
i.putExtra("address","9982347135");
i.putExtra("sms_body","body");
i.putExtra(Intent.EXTRA_STREAM,Uri.parse(path));
i.setType("image/*");
startActivity(i);
}
TRY that one. hopefully it works!!