Zum Inhalt springen
Skillpedia
Mobile Apps10k · #11908

camerax

Was er macht

Dieser Skill gibt Anleitungen und Muster für Kamerafunktionen in Android-Apps mit der Bibliothek CameraX. Er ist für Android-Entwickler gedacht, die Fotos, Video oder Effekte in eine App einbauen wollen.

Wann du ihn nutzt

  • ✓Wenn du einen Kamera- oder Videoaufnahme-Bildschirm in eine Android-App einbauen willst.
  • ✓Wenn du älteren Kamera-Code auf CameraX umstellen musst.
  • ✓Wenn du ML-Kit- oder Media3-Effekte in einen Kamera-Stream einbauen willst.

Link zum Skill

https://github.com/android/skills/blob/main/camera/camerax/SKILL.md

Kopiere ihn und füge ihn in deine KI ein (Claude, ChatGPT oder Cursor) mit der Bitte, den Anweisungen zu folgen.

So nutzt du ihn

Am einfachsten: Kopiere die Nachricht und füge sie in deine KI ein. Sie liest den Skill und folgt den Anweisungen.

Fertige Nachricht zum Einfügen

Nutze diesen Skill, um mir zu helfen: https://github.com/android/skills/blob/main/camera/camerax/SKILL.md Lies die SKILL.md unter diesem Link und folge ihren Anweisungen für meine Aufgabe.
Soll deine KI Skills wie diesen selbst finden?Installiere den kostenlosen Skillpedia-MCP: eine Zeile, und sie durchsucht vor jeder Aufgabe 15.000+ Skills.In 1 Minute installieren →

Beispielanfrage an deine KI

“Füge meiner Android-App mit CameraX eine Videoaufnahme mit Ton hinzu.”

5 neue Skills pro Woche. 1 Minute Lesezeit.

So funktioniert es

Der Skill beschreibt Schritt für Schritt Muster für die Bibliothek CameraX. Er weist auf Builder-Aufrufe hin, die zurückgespeichert werden müssen, damit sie wirken, und behandelt die Anbindung an Hardware und Effekte.

Technischer Inhalt (originale SKILL.md)

Originaltext des Autors, auf Englisch, direkt von GitHub.

This skill provides procedural guidance and standard patterns for building camera applications on Android, with a focus on CameraX, including its Camera2Interop utilities, and Media3 integrations.

Core workflows

Handling immutable API patterns

Various Android camera and media APIs, especially CameraX VideoCapture, use a fluent, immutable builder-like pattern where methods return a new instance. Failing to reassign these results in settings, such as audio, being ignored.

Pattern: Reassignment is required

// WRONG
run {
  val pending = recorder.prepareRecording(context, opts)
  pending.withAudioEnabled() // This returns a new instance which is ignored
  val active = pending.start(exec, listener)
}

// CORRECT
run {
  val pending = recorder.prepareRecording(context, opts)
      .withAudioEnabled() // Chaining works
  val active = pending.start(exec, listener)
}

// ALSO CORRECT
run {
  var pending = recorder.prepareRecording(context, opts)
  pending = pending.withAudioEnabled() // Reassignment
  val active = pending.start(exec, listener)
}
<br />

See immutability for a list of affected classes.

Migrating to CameraX

When migrating legacy camera codebases to the CameraX Jetpack library:

  • Camera1 to CameraX : For migrating legacy android.hardware.Camera implementations, surface handling, and manual lifecycles, see the Camera1 migration guide.
  • Camera2 to CameraX : For migrating more recent but verbose android.hardware.camera2 implementations, session state callbacks, and interop patterns, see the Camera2 migration guide.

Comprehensive feature blueprinting

For multi-step features that involve multiple files and hardware-level wiring, follow the Structural Blueprinting approach to avoid system timeouts. Such complex features include:

  • Manual controls : Break down into the ViewModel state, the controller layer, and the Camera2Interop wiring in the session.
  • RAW capture: Separate JPEG and RAW output configurations into discrete build steps.
  • Custom effects : Prefer Media3Effect or SurfaceProcessor over manual OpenGL pipelines unless absolute performance is required.
  • Low-light : See low-light for Night Mode and LLB guidance.
  • Foldables : See foldables for handling dynamic postures and hinge states.
  • XR, AR, and VR : See xr for spatial tracking, passthrough synchronization, and latency guardrails.
  • Thermals and power : See thermals for managing StreamUseCase optimizations and PowerManager thermal states.
  • Testing and mocking : See testing for using FakeCameraConfig, handling asynchronous lifecycles, and validating analysis pipelines.
  • ML Kit spatial analysis : See mlkit-spatial for coordinate mapping, rotation logic, and mirrored lens handling.
  • Wear OS camera remote : See wear-os for circular UI constraints, Data Layer API syncing, and remote trigger logic.

See expert-blueprints for step-by-step guides.

API discovery

Always use higher-level abstractions instead of low-level manual wiring:

  • Analysis : Use MlKitAnalyzer instead of manual ImageAnalysis.Analyzer.
  • Filters and effects : Use Media3Effect for standard post-processing.
  • Multi-camera : Use ConcurrentCamera APIs for dual-stream setups.

See modern-apis for current recommendations.

Code quality and architectural rules

Adhere to the following Android ecosystem standard patterns when building your camera implementations:

  • Testing, fakes over mocks : Avoid mocking libraries like Mockito, especially for multi-step CameraX interfaces like ImageProxy. Build "Fakes" to verify state rather than unreliable implementation details.
  • Google Truth assertions : Use assertThat over standard JUnit assertions like assertEquals for improved readability.
  • Explicit test runners : Always define an explicit @RunWith for test classes to ensure the CI environment executes them correctly.
  • Semantic UI merging : When building custom camera controls in Compose, such as a button with an Icon and Text, use `semantics {
Häufige Fragen

Warum werden meine Audioeinstellungen ignoriert?

Manche Methoden von CameraX liefern ein neues Objekt zurück, das gespeichert werden muss. Der Skill weist darauf hin.

Kann er beim Wechsel von der alten Kamera-API helfen?

Ja. Er enthält Hinweise zur Migration von altem Camera-Code auf CameraX.

Deckt er ML Kit ab?

Ja. Er behandelt das Hinzufügen von ML-Kit- oder Media3-Effekten zu einem CameraX-Aufbau.

Details

Originalbeschreibung des Autors

Provide technical guidance for Android camera development with CameraX. Use when implementing camera features, handling asynchronous recording lifecycles, wiring low-level hardware interop using CameraX, or integrating ML Kit or Media3 effects.

repo: android/skills

Beliebtheit

GitHub-Sterne
10k
Platz im Ranking
#11908
Lizenz
Apache-2.0
Aktualisiert
29.10.2026

Ist dieser Skill nützlich?

0

Anmelden um abzustimmen.

Kommentare

  • …

Weitere Skills aus diesem Repository

Ähnliche Skills