Skip to content Skip to sidebar Skip to footer

How To Control/save Images Took With Android Camera Programmatically?

i've been trying to create a camera-related app. i know that i could create it programmatically from top, but i would prefer using the one that the phone supports. what i mean is,

Solution 1:

Try this. Here am saving picture to sdcard and also changing its name while saving.

Intentintent=newIntent(MediaStore.ACTION_IMAGE_CAPTURE);

UrimUri= Uri.fromFile(newFile(Environment.getExternalStorageDirectory(),
                "pic"+ String.valueOf(System.currentTimeMillis()) + ".jpg"));

intent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, mUri);

Solution 2:

If you look at the Camera applicaton source code, it allows for startActivityForResult(..) that can return the image back to you. This is ideally what you'd like to do.

As a Little hint:

MediaStore

Solution 3:

Use below method to take picture, SD_CARD_TEMP_DIR is the path and the image name you want it to store. Hope it help

privatevoidtakePicture(){

    SD_CARD_TEMP_DIR = Environment.getExternalStorageDirectory() + File.separator + "farmerImage"+CassavaPref.getInstance(this).getImageSuffix()+".jpg";
    file =new File(SD_CARD_TEMP_DIR);
    Intent takePictureFromCameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    takePictureFromCameraIntent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, Uri.fromFile(file));
    startActivityForResult(takePictureFromCameraIntent, 1111);
}

Post a Comment for "How To Control/save Images Took With Android Camera Programmatically?"