about uscontact

[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.


Professional software development agency estalished in Indonesia. We offers website setup, web application development, fulfillment service, and etc.
Follow us
Follow us to get latest news and tutorials.
2022 - Copyright, All Rights Reserved, Made by ZEMNA.NET with ❤️