Programming/Android
카메라 인텐트로 띄운후 해당 이미지 ImageView에 띄우기
TanSanC
2013. 5. 16. 23:32
카메라 인텐트로 띄운후 해당 이미지 ImageView에 띄우기
1. 카메라 인텐트 띄우기
Intent intent = new Intent(); intent.setAction(MediaStore.ACTION_IMAGE_CAPTURE); startActivityForResult(intent, 1);
2. 갤러리 인텐트 띄우기
Intent intent = new Intent();
intent.setAction(Intent.ACTION_GET_CONTENT);
intent.setType("image/*");
startActivityForResult(intent, 2);
인텐트 후 Image 불러오기
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
if (resultCode == RESULT_OK)
{
if (requestCode == 1) // 1 은 위에서 startActivityForResult(intent, 1);
{
ImageView imageView1 = (ImageView)findViewById(R.id.imageView1);
Bitmap bm = (Bitmap) data.getExtras().get("data");
imageView1.setImageBitmap(bm);
}
}
}