hi everyone,
i am trying to open camera take a pic and save that pic to my folder in sd
card . I am able to open camera and take pic but it is not saving on my
folder here is the code
protected void startCameraActivity() {
Button startRec = ((Button) findViewById(R.id.btncamon));
startRec.setVisibility(View.VISIBLE);
Log.i("MakeMachine", "startCameraActivity()");
imageFilePath = getFilename() ;
file = new File(imageFilePath);
outputFileUri = Uri.fromFile(file);
/*Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
startActivityForResult(intent, 0);*/
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
// file = new File(Environment.getExternalStorageDirectory(),
ReceiptData.PICTURE_PATH + String.valueOf(System.currentTimeMillis()) +
".jpg");
intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
startActivityForResult(intent, 1);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent
data) {
if (requestCode == 1) {
switch( resultCode ) {
case 0:
break;
case -1:
setupImage(data);
break;
}
}
}
public Bitmap setupImage(Intent data) {
BitmapFactory.Options options = new BitmapFactory.Options();
options.inSampleSize = 4; // SAMPLE_SIZE = 2
Bitmap tempBitmap = null;
Bitmap bm = null;
try {
tempBitmap = (Bitmap) data.getExtras().get("data");
bm = tempBitmap;
Log.v("ManageImage-hero", "the data.getData seems to be valid");
FileOutputStream out = new FileOutputStream(file);
tempBitmap.compress(Bitmap.CompressFormat.JPEG, 100, out);
} catch (NullPointerException ex) {
Log.v("ManageImage-other", "another phone type");
bm = otherImageProcessing(options);
} catch(Exception e) {
Log.e("ManageImage-setupImage", "problem setting up the image",
e);
}
return bm;
}
private Bitmap otherImageProcessing(BitmapFactory.Options options) {
Bitmap bm = null;
try {
FileInputStream fis = new FileInputStream(file);
BufferedInputStream bis = new BufferedInputStream(fis);
bm = BitmapFactory.decodeStream(bis, null, options);
// cleaning up
fis.close();
bis.close();
} catch(Exception e) {
Log.e("ManageImage-otherImageProcessing", "Cannot load image",
e);
}
return bm;
}
thanks
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en