himanshu
himanshu

Reputation: 1980

Android camera intent confusion

I am working on an app in which i have to click a pic a pic and save it to a specified folder. I am using android.provider.MediaStore.ACTION_IMAGE_CAPTURE in intent to invoke the camera .I am done with coding and my activity is working fine.But now i have a question in my mind that whether i should stick with this code or i should use the code given here.Need your precious suggestions on this topic.

Thanx in advance.

Upvotes: 0

Views: 409

Answers (3)

Thommy
Thommy

Reputation: 5407

I suggest you use the code from your link. Because most of the stock camera apps don't work as expected with Image Capture. For example the Galaxy S2 and most other Samsung and HTC phones give you the picture bytes back and also save the picture in the standard DCIM Folder on SD-Card, if you want it or not.

Upvotes: 1

user370305
user370305

Reputation: 109237

If you want to just click a picture and save it to a specified folder nothing more then You can use Intent and call ACTION_IMAGE_CAPTURE, it easy to let handle on camera activity do your stuff,

And If your application has some serious deep work with camera when you want to modify preview screen size, and all those things,(For this you have to handle all things like to manage camera, and when to release it, check for don't freeze main UI..) then you have to go with the code you suggested...

Choice is yours.....

Upvotes: 1

NikhilReddy
NikhilReddy

Reputation: 6954

public void imageFromCamera() {
    Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
    if (!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)){
        Log.d(TAG, "No SDCARD");
    } else {
        mImageFile = new File(Environment.getExternalStorageDirectory()+File.separator+"MyApp",  
            "PIC"+System.currentTimeMillis()+".jpg");
        mTempImagePath = mImageFile.getAbsolutePath();
        intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(mImageFile));
        startActivityForResult(intent, TAKE_PICTURE);
    }
}

this what u r searching i am thinking..

Upvotes: 0

Related Questions