Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- Gradle
- 웹뷰
- Github
- 에러
- coroutine
- 깃헙
- 안드로이드 스튜디오
- WebView
- 안스
- flow
- RecyclerView
- 유튜브
- studio
- 코루틴
- 의존성주입
- ADB
- 레트로핏
- Android
- 스튜디오
- build
- MVVM
- viewpager
- image
- 안드로이드스튜디오
- 코틀린
- Retrofit
- dart
- error
- Kotlin
- 안드로이드
Archives
- Today
- Total
코딩하는 일용직 노동자
Photo Picker - Android13 본문
Android 13 Preview에 새로운 사진 선택 도구가 포함되었습니다.
이 라이브러리는 향후 Android 11(API 레벨 30) 이상의 앱을 지원합니다.
앱에 전체 미디어 라이브러리에 대한 액세스 권한을 부여하지 않고도 사용자가 미디어 파일을 선택할 수 있는 안전한 기본 제공 방법을 제공해줍니다.
사용자가 사진 또는 비디오만 볼 수 있도록 지정할 수 있으며 설정에 따라 1장만 선택할 수도, 여러개의 사진을 선택할 수도 있습니다.
- 사진 1장만 선택할때
// Launches photo picker in single-select mode.
// This means that the user can select one photo or video.
Intent intent = new Intent(MediaStore.ACTION_PICK_IMAGES);
startActivityForResult(intent, PHOTO_PICKER_REQUEST_CODE);
- 여러장을 선택할때
// Launches photo picker in multi-select mode.
// This means that user can select multiple photos/videos, up to the limit
// specified by the app in the extra (10 in this example).
final int maxNumPhotosAndVideos = 10;
Intent intent = new Intent(MediaStore.ACTION_PICK_IMAGES);
intent.putExtra(MediaStore.EXTRA_PICK_IMAGES_MAX, maxNumPhotosAndVideos);
startActivityForResult(intent, PHOTO_PICKER_MULTI_SELECT_REQUEST_CODE);
- 선택한 사진은 onActivityResult() 를 통해 전달받습니다.
// onActivityResult() handles callbacks from the photo picker.
@Override
protected void onActivityResult(
int requestCode, int resultCode, final Intent data) {
if (resultCode != Activity.RESULT_OK) {
// Handle error
return;
}
switch(requestCode) {
case REQUEST_PHOTO_PICKER_SINGLE_SELECT:
// Get photo picker response for single select.
Uri currentUri = data.getData();
// Do stuff with the photo/video URI.
return;
case REQUEST_PHOTO_PICKER_MULTI_SELECT:
// Get photo picker response for multi select
for (int i = 0; i < data.getClipData().getItemCount(); i++) {
Uri currentUri = data.getClipData().getItemAt(i).getUri();
// Do stuff with each photo/video URI.
}
return;
}
}
- 동영상만 선택할때
// Launches photo picker for videos only in single select mode.
Intent intent = new Intent(MediaStore.ACTION_PICK_IMAGES);
intent.setType("video/*");
startActivityForResult(intent, PHOTO_PICKER_VIDEO_SINGLE_SELECT_REQUEST_CODE);
// Apps can also change the mimeType to allow users to select
// images only - intent.setType("images/*");
// or a specific mimeType - intent.setType("image/gif");
https://developer.android.com/about/versions/13/features/photopicker
Photo picker | Android 13 Developer Preview | Android Developers
Welcome to the Android 13 Developer Preview! Please give us your feedback, and help us make Android 13 the best release yet. Photo picker Figure 1. Photo picker provides an intuitive UI for sharing photos with your app. Android 13 includes support for a n
developer.android.com
'안드로이드' 카테고리의 다른 글
무료 아이콘(icon) 제공 사이트 (0) | 2022.03.03 |
---|---|
인앱리뷰(InApp Review) 구현하기 (2) | 2022.02.23 |
위치권한을 요청하고, GPS 기능까지 켜도록 하는 예제 (0) | 2022.02.08 |
무선 디버깅(Wireless debugging) 기능 이용방법. (0) | 2022.02.06 |
ADB 명령어로 딥링크 테스트 하는 방법 (0) | 2022.02.03 |