동영상 녹화
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
참고: 이 페이지에서는 지원 중단된 Camera 클래스를 다룹니다. CameraX 또는 특정 사용 사례의 경우 Camera2를 사용하는 것이 좋습니다. CameraX와 Camera2는 모두 Android 5.0(API 수준 21) 이상을 지원합니다.
이 과정에서는 기존 카메라 애플리케이션을 사용하여 동영상을 캡처하는 방법에 관해 설명합니다.
애플리케이션은 해야 할 작업이 있고 동영상을 통합하는 것은 애플리케이션의 작은 부분일 뿐입니다. 캠코더를 다시 개발하지 않고 최소한의 노력으로 동영상을 찍고 싶을 것입니다. 다행히 대부분의 Android 지원 기기에는 이미 동영상을 녹화하는 카메라 애플리케이션이 있습니다. 이 과정에서는 카메라 애플리케이션을 사용하여 동영상을 녹화하는 방법을 알아봅니다.
카메라 기능 요청
애플리케이션이 카메라를 필요로 하는지 알리려면 다음과 같이 매니페스트 파일에 <uses-feature>
태그를 삽입합니다.
<manifest ... >
<uses-feature android:name="android.hardware.camera"
android:required="true" />
...
</manifest>
애플리케이션에서 카메라를 사용하기는 하지만 작동하는 데 필요한 것이 아니라면 android:required
를 false
로 설정합니다. 그렇게 하면 Google Play에서 카메라가 없는 기기도 애플리케이션을 다운로드할 수 있습니다. 그런 다음 앱은 런타임 시 hasSystemFeature(PackageManager.FEATURE_CAMERA)
를 호출하여 카메라의 사용 가능 여부를 확인해야 합니다.
카메라를 사용할 수 없는 경우 카메라 기능을 중지합니다.
동영상 보기
Android 카메라 애플리케이션은 onActivityResult()
에 전달된 Intent
에 저장소의 동영상 위치를 가리키는 Uri
로 동영상을 반환합니다. 다음 코드는 이 동영상을 가져와서 VideoView
에 표시하는 방법을 보여줍니다.
Kotlin
override fun onActivityResult(requestCode: Int, resultCode: Int, intent: Intent) {
if (requestCode == REQUEST_VIDEO_CAPTURE && resultCode == RESULT_OK) {
val videoUri: Uri = intent.data
videoView.setVideoURI(videoUri)
}
}
Java
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
if (requestCode == REQUEST_VIDEO_CAPTURE && resultCode == RESULT_OK) {
Uri videoUri = intent.getData();
videoView.setVideoURI(videoUri);
}
}
이 페이지에 나와 있는 콘텐츠와 코드 샘플에는 콘텐츠 라이선스에서 설명하는 라이선스가 적용됩니다. 자바 및 OpenJDK는 Oracle 및 Oracle 계열사의 상표 또는 등록 상표입니다.
최종 업데이트: 2025-07-26(UTC)
[null,null,["최종 업데이트: 2025-07-26(UTC)"],[],[],null,["# Record videos\n\n**Note:** This page refers to the\n[Camera](/reference/android/hardware/Camera) class, which is deprecated. We\nrecommend using [CameraX](/media/camera/camerax) or, for specific use cases,\n[Camera2](/media/camera/camera2). Both CameraX and Camera2 support Android 5.0\n(API level 21) and higher.\n\nThis lesson explains how to capture video using existing camera\napplications.\n\nYour application has a job to do, and integrating videos is only a small\npart of it. You want to take videos with minimal fuss, and not reinvent the\ncamcorder. Happily, most Android-powered devices already have a camera application that\nrecords video. In this lesson, you make it do this for you. \n\nRefer to the following related resources:\n\n- [Camera](/guide/topics/media/camera)\n- [Intents and Intent\n Filters](/guide/components/intents-filters)\n\nRequest the camera feature\n--------------------------\n\nTo advertise that your application depends on having a camera, put a\n`\u003cuses-feature\u003e` tag in the manifest file: \n\n```xml\n\u003cmanifest ... \u003e\n \u003cuses-feature android:name=\"android.hardware.camera\"\n android:required=\"true\" /\u003e\n ...\n\u003c/manifest\u003e\n```\n\nIf your application uses, but does not require a camera in order to function, set `android:required` to `false`. In doing so, Google Play will allow devices without a\ncamera to download your application. It's then your responsibility to check for the availability\nof the camera at runtime by calling [hasSystemFeature(PackageManager.FEATURE_CAMERA)](/reference/android/content/pm/PackageManager#hasSystemFeature(java.lang.String)).\nIf a camera is not available, you should then disable your camera features.\n\nView the video\n--------------\n\nThe Android Camera application returns the video in the [Intent](/reference/android/content/Intent) delivered\nto [onActivityResult()](/reference/android/app/Activity#onActivityResult(int, int, android.content.Intent)) as a [Uri](/reference/android/net/Uri) pointing to the video location in storage. The following code\nretrieves this video and displays it in a [VideoView](/reference/android/widget/VideoView). \n\n### Kotlin\n\n```kotlin\noverride fun onActivityResult(requestCode: Int, resultCode: Int, intent: Intent) {\n if (requestCode == REQUEST_VIDEO_CAPTURE && resultCode == RESULT_OK) {\n val videoUri: Uri = intent.data\n videoView.setVideoURI(videoUri)\n }\n}\n```\n\n### Java\n\n```java\n@Override\nprotected void onActivityResult(int requestCode, int resultCode, Intent intent) {\n if (requestCode == REQUEST_VIDEO_CAPTURE && resultCode == RESULT_OK) {\n Uri videoUri = intent.getData();\n videoView.setVideoURI(videoUri);\n }\n}\n```"]]