開始使用 Android 相機
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
相機支援多種應用程式用途,例如擷取要分享到社群媒體的影片和圖片,以及掃描文件和 QR code 等公用程式。這個開發人員中心提供說明文件和資源,協助您開始在 Android 應用程式中使用相機。
建構相機應用程式
如要建構相機式應用程式,或將相機整合至現有應用程式,請先探索 CameraX API,這個 API 簡單易用,可用於使用相機。本總覽將介紹 CameraX,並逐步說明如何使用相機。
CameraX 總覽
CameraX 程式碼研究室會提供範例式,協助您學習 CameraX。
CameraX 程式碼研究室
從 Camera1 遷移
如果您的應用程式使用已淘汰的 Camera 類別 (「Camera1」),建議您改用 CameraX,這個平台會提供穩定可靠的平台,讓應用程式能善用新的相機功能。
從 Camera1 遷移至 CameraX
升級相機應用程式
CameraX 有助於直接與 MLKit 程式庫 (MLKit) 整合。這可以讓相機與 MLKit 結合,以產生 QR 掃描器和文件掃描器等項目。
建立 QR code 掃描器
可讓應用程式存取特殊的裝置功能,例如夜間模式影像拍攝或散景 (肖像) 模式。如要瞭解如何同時使用 CameraX 和 Camera2 存取 Camera Extensions,請按這裡。
擴充應用程式的相機體驗
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。Java 與 OpenJDK 是 Oracle 和/或其關係企業的商標或註冊商標。
上次更新時間:2025-07-27 (世界標準時間)。
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-07-27 (世界標準時間)。"],[],[],null,["# Get started with camera on Android\n\nThe camera enables an exciting range of application use cases such as capturing\nvideo and images for sharing with social media, to creating utilities such as\ndocument and QR Code scanning. This developer center provides documentation and\nresources to get started using the camera in your Android application.\n\nBuild a camera application\n--------------------------\n\nTo build a camera based application or incorporate camera into your\nexisting application, start by exploring the CameraX API: a streamlined API\nfor using the camera. This overview introduces CameraX and walks through\nsteps to use the camera.\n\n[Overview of CameraX](/media/camera/camerax)\n\nThe CameraX Codelab provides an example based approach to learning CameraX.\n\n[CameraX Codelab](/codelabs/camerax-getting-started)\n\nMigrate from Camera1\n--------------------\n\nIf your app uses the deprecated Camera class (\"Camera1\"), consider\nperforming a migration to CameraX, which will provide a stable and\nrobust platform that allows your application to take advantage of new camera\ncapabilities.\n\n[Migrate Camera1 to CameraX](/media/camera/camerax/camera1-to-camerax)\n\nLevel up your camera application\n--------------------------------\n\nCameraX facilitates direct integration with the [Machine Learning Toolkit\nlibrary](https://developers.google.com/ml-kit), MLKit. This allows camera to be\ncombined with MLKit to create things like QR scanners, document scanners and\nmore.\n\n[Create a QR Code scanner](/media/camera/camerax/mlkitanalyzer)\n\nCamera Extensions allows your application access to special device capabilities\nsuch as Night Mode image capture or Bokeh (Portrait) modes. Learn how to access\nCamera Extensions using both CameraX and Camera2 here.\n\n[Extend your app's camera experience](/media/camera/camerax/extensions-api)"]]