Take a photo with a camera app and get the thumbnail
Android 2019. 10. 18. 16:42 |반응형
Explains how to take a photo and get the thumbnail of it in an easy way.
기기의 카메라 앱을 실행 시키고 사진을 찍어 썸네일을 가져 온다.
<AndroidManifest.xml>
1 | <uses-feature android:name="android.hardware.camera" android:required="true"/> |
<MainActivity.java>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | public class MainActivity extends AppCompatActivity { static final int REQUEST_IMAGE_CAPTURE = 1001; ImageView imageView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); imageView = findViewById(R.id.imageView); Button button = findViewById(R.id.button); button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); if (intent.resolveActivity(getPackageManager()) != null) { startActivityForResult(intent, REQUEST_IMAGE_CAPTURE); } } }); } @Override protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { if (requestCode == REQUEST_IMAGE_CAPTURE && resultCode == RESULT_OK) { Bundle extras = data.getExtras(); Bitmap bitmap = (Bitmap)extras.get("data"); imageView.setImageBitmap(bitmap); } } } |
Run the app and click CAMERA button.
Take a picture.
Get the thumbnail.
반응형
'Android' 카테고리의 다른 글
Stream an audio file with MediaPlayer 오디오 파일 스트리밍 하기 (0) | 2019.10.21 |
---|---|
Take a photo with a camera app and save the full-size photo (0) | 2019.10.18 |
Get contact data 연락처 정보 가져오기 (0) | 2019.10.16 |
Get multiple sensor data 여러가지 센서 데이터 받아 오기 (0) | 2019.10.15 |
Character encoding simple check 간단한 한글 인코딩 확인 (0) | 2019.10.12 |