I want to make application in which i want to use camera as after the image is captured, i want to store that image in SDCard and display that image in Screen too.
C
Use ACTION_IMAGE_CAPTURE
intent to launch Camera Activity:
Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE );
startActivityForResult( intent, 0 );
Have a detailed example here: http://labs.makemachine.net/2010/03/simple-android-photo-capture/ , which i think suitable to your problem as to capture image , store it in sd-card and then display image in imageview too.
Enjoy!!!
You can invoke system camera use below method:
private void startCameraActivity() {
File file = new File("/sdcard/test/test.jpg");
Uri outputFileUri = Uri.fromFile(file);
Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
startActivityForResult(intent, REQUEST_CODE_CAMERA);
}
when the invoke finished, you will get the picture use onActivityResult:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
Log.i("MakeMachine", "requestCode:"+requestCode + ",resultCode: " + resultCode);
switch(requestCode){
case ModifyUserActivity.REQUEST_CODE_CAMERA:
switch (resultCode) {
case Activity.RESULT_CANCELED:
picFileName = null;
Log.i("MakeMachine", "User cancelled");
break;
case Activity.RESULT_OK:
File file = new File("/sdcard/test/test.jpg");
if(file.exists()){
BitmapFactory.Options options = new BitmapFactory.Options();
options.inSampleSize = 4;
Bitmap bitmap = BitmapFactory.decodeFile(picFileName, options);
imgTakePhoto.setImageBitmap(bitmap);
imgTakePhoto.setVisibility(View.VISIBLE);
}
break;
default:
break;
}
break;
default:
break;
}
}