[Android] Get image from Camera

Author: zemna
Date: April 17, 2021
Share this:


카메라 촬영 액티비티를 호출하고 onActivityResult() 함수를 통해 찍힌 이미지에 접근하는 소스

카메라 호출 소스

[code lang="java"] Intent i = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); startActivityForResult(i, 1004); [/code]

찍은 이미지 가져오기 소스

[code lang="java"] protected void onActivityResult(int requestCode, int resultCode, Intent data) {

super.onActivityResult(requestCode, resultCode, data);

if (requestCode == 1004 && resultCode == RESULT_OK) {

try { Bitmap profileBitmap = (Bitmap) data.getExtras().get("data");

ImageBox.setImageBitmap(profileBitmap); ImageBox.setScaleType(ImageView.ScaleType.FIT_XY); } catch (Exception e) {

} } } [/code]

Share this:

Leave a Reply

Your email address will not be published. Required fields are marked *

Let's connect and create
something awesome together!
2023 - Copyright, All Rights Reserved, Made by ZEMNA.NET with ❤️
crossmenu linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram