The following Code works for HTC but not on Samsung Galaxy:
final Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT,
Uri.fromFile(getTempFile(this)) );
startActivityForResult(intent, TAKE_PHOTO_CODE);
private File getTempFile(Context context){
File path = new File( Environment.getExternalStorageDirectory(),
context.getPackageName() );
if(!path.exists()){
path.mkdir();
}
return new File(path, "image.tmp");
}
@Override
protected void onActivityResult(int requestCode, int resultCode,
Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == RESULT_OK) {
switch(requestCode){
case TAKE_PHOTO_CODE:
final File file = getTempFile(this);
captureBmp = Media.getBitmap(getContentResolver(),
Uri.fromFile(file) );
int width = captureBmp.getWidth();
int height = captureBmp.getHeight();
int newWidth = width - ((width*40)/100);
int newHeight = height - ((height*40)/100);
float scaleWidth = ((float) newWidth) / width;
float scaleHeight = ((float) newHeight) / height;
Matrix matrix = new Matrix();
matrix.postScale(scaleWidth, scaleHeight);
resizedBitmap = Bitmap.createBitmap(captureBmp, 0, 0,
width, height, matrix, true);
bmd = new BitmapDrawable(resizedBitmap);
ImageView iv = (ImageView) findViewById (R.id.iv_foto_beleg);
iv.setImageDrawable(bmd);
SharedPreferences sharedPreferences = getPreferences(MODE_PRIVA
long id = sharedPreferences.getLong("id", 0);
break;
}
}
After press saving the camera activity does not turn back to the
activity, which launched the it. The picture is not on sdcard. Is
there anybody can help? Thanks in advance.
Greetings
--
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