Hello i have build an android app which uses the camera to take a picture and then send it as a email attachment.
Its works fine on a htc phone but it does not work on a samsung galaxy which only sends a empty attachment to my mail.
Does someone have a suggestion how to fix this?
my code:
private final static int TAKE_PHOTO_CODE = 1;
File downloadedPic = null;
Intent in;
boolean taken = false;
//NEW
private static int TAKE_PICTURE = 1;
private Uri outputFileUri;
private void TakePhoto() {
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
File file = new File(
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), "fotowedstrijd.jpeg");
outputFileUri = Uri.fromFile(file);
intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
startActivityForResult(intent, TAKE_PICTURE);
}
private void sendPhoto(){
Intent picMessageIntent = new Intent(Intent.ACTION_SEND);
picMessageIntent.putExtra(Intent.EXTRA_EMAIL , new String[]{"info@wemait.nl"}); //fotowedstrijd@openbedrijvendagemmen.nl
picMessageIntent.putExtra(Intent.EXTRA_SUBJECT, "Fotowedstrijd inzending Openbedrijvendag Emmen");
picMessageIntent.putExtra(Intent.EXTRA_TEXT , "Mijn inzending voor de fotowedstrijd");
picMessageIntent.setType("image/jpeg");
File downloadedPic = new File(
Environment.getExternalStoragePublicDirectory(
Environment.DIRECTORY_PICTURES),
"fotowedstrijd.jpeg");
picMessageIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(downloadedPic));
startActivity(picMessageIntent);
//startActivity(Intent.createChooser(picMessageIntent, "Send your picture using:"));
}
What I found: Android ACTION_IMAGE_CAPTURE Intent
what it says is that there might be a bug with MediaStore.ACTION_IMAGE_CAPTURE.
Something else, that came to my mind: Maybe the directory doesn't exist on your samsung phone, so you have to create it first.
just some first guesses.