Notice
Recent Posts
Recent Comments
올해는 머신러닝이다.
camera intent 관련 flag 팁 본문
private Uri imageUri;
public void takePhoto(View view) {
Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
File photo = new File(Environment.getExternalStorageDirectory(), "Pic.jpg");
intent.putExtra(MediaStore.EXTRA_OUTPUT,
Uri.fromFile(photo));
imageUri = Uri.fromFile(photo);
startActivityForResult(intent, TAKE_PICTURE);
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
switch (requestCode) {
case TAKE_PICTURE:
if (resultCode == Activity.RESULT_OK) {
Uri selectedImage = imageUri;
getContentResolver().notifyChange(selectedImage, null);
ImageView imageView = (ImageView) findViewById(R.id.ImageView);
ContentResolver cr = getContentResolver();
Bitmap bitmap;
try {
bitmap = android.provider.MediaStore.Images.Media
.getBitmap(cr, selectedImage);
imageView.setImageBitmap(bitmap);
Toast.makeText(this, selectedImage.toString(),
Toast.LENGTH_LONG).show();
} catch (Exception e) {
Toast.makeText(this, "Failed to load", Toast.LENGTH_SHORT)
.show();
Log.e("Camera", e.toString());
}
}
}
}
'Android > Tip&Tech' 카테고리의 다른 글
android 퍼미션 종류별 정리 (2) | 2011.06.24 |
---|---|
루팅폰 확인하기 (0) | 2011.06.23 |
android Badge 참고사항(카운트) (0) | 2011.06.20 |
[팁] Android에서 SAX를 이용한 Parsing 방법 (0) | 2011.06.20 |
[android]listView 항목 드래그앤드랍 하기 (0) | 2011.06.20 |