The main process of camera application development includes development preparations, device input management, session management, preview, photo capture, and video recording.
Before developing a camera application, you must request camera-related permissions to ensure that the application has the permission to access the camera device and other services. Before requesting permissions, ensure that the basic principles for using permissions are met.
- To use the camera for photo capture, request the ohos.permission.CAMERA permission.
- To use the microphone to record audio, request the ohos.permission.MICROPHONE permission.
- To display location information in photos or videos captured, request the ohos.permission.MEDIA_LOCATION permission.
All these permissions must be authorized by users through a dialog box. For details about how to request and verify the permissions, see Declaring Permissions and Requesting User Authorization.
- When the user denies authorization in the dialog box, you can call isCameraMuted to check whether the camera is currently muted.
- Only when the app needs to clone, back up, or sync image and video files in the user's public directory, can you apply for the ohos.permission.READ_IMAGEVIDEO and ohos.permission.WRITE_IMAGEVIDEO permissions to read and write image/video files. For details about how to apply, see Requesting Restricted Permissions, which can be used only after being approved by AppGallery Connect (AGC). To prevent the application release request from being rejected, you are advised to use alternative solutions such as Pickers and components preferentially. Restricted permissions are granted only when the related conditions are met.