百科.dev
全部条目AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
C

CameraFragment

> 开发工具
开源

一个简单易于集成的 Android 相机片段

2.3K stars0 点赞0 次浏览
访问官网GitHub

工具介绍

一个简单易于集成的 Android 相机片段

CameraFragment

A simple easy-to-integrate Camera Fragment for Android

CameraFragment preview directly the camera view, and provides a easy API to capture or manage the device

You can setup your own layout and control the camera using CameraFragment

CameraKit

This library works, but on some devices... errors happens, I don't have time to maintain compatibility with all device A community group was created, they created CameraKit, don't hesitate to try it !

https://github.com/CameraKit/camerakit-android

Setup

//you can configure the fragment by the configuration builder
CameraFragment cameraFragment = CameraFragment.newInstance(new Configuration.Builder().build());

getSupportFragmentManager().beginTransaction()
                .replace(R.id.content, cameraFragment, FRAGMENT_TAG)
                .commit();

Actions

You can directly take a photo / video with

cameraFragment.takePhotoOrCaptureVideo(callback);
cameraFragment.takePhotoOrCaptureVideo(callback, directoryPath, fileName);

Flash can be enable / disabled ( AUTO / OFF / ON ) with

cameraFragment.toggleFlashMode();

Camera Type can be modified ( BACK / FRONT ) with

cameraFragment.switchCameraTypeFrontBack();

Camera action ( PHOTO / VIDEO ) can be modified with

cameraFragment.switchActionPhotoVideo();

And you can change the captured photo / video size with

cameraFragment.openSettingDialog();

Listeners

Result

Get back the result of the camera record / photo in the CameraFragmentResultListener

cameraFragment.setResultListener(new CameraFragmentResultListener() {
       @Override
       public void onVideoRecorded(byte[] bytes, String filePath) {
                //called when the video record is finished and saved

                startActivityForResult(PreviewActivity.newIntentVideo(MainActivity.this, filePath));
       }

       @Override
       public void onPhotoTaken(byte[] bytes, String filePath) {
                //called when the photo is taken and saved

                startActivity(PreviewActivity.newIntentPhoto(MainActivity.this, filePath));
       }
});

Camera Listener

…

Text

CameraFragment can ping you with the current record duration with CameraFragmentTextListener

Widgets

CameraFragment comes with some default views

RecordButton, MediaActionSwitchView, FlashSwitchView, CameraSwitchView, CameraSettingsView

Download

In your module

implementation 'com.github.florent37:camerafragment:1.0.10'

Community

Forked from https://github.com/memfis19/Annca

This library works, but on some devices... errors happens, I don't have time to maintain compatibility with all device A community group was created, they created CameraKit, don't hesitate to try it !

https://github.com/CameraKit/camerakit-android

Credits

Author: Florent Champigny http://www.florentchampigny.com/

Blog : http://www.tutos-android-france.com/

Fiches Plateau Moto : https://www.fiches-plateau-moto.fr/

License

Copyright 2017 florent37, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

GitHub Issues· 0 开放

在 GitHub 查看全部

暂无开放 Issues,或尚未同步最近议题。

核心特点

  • •Java
  • •android
  • •api
  • •camera
  • •capture

> 标签

Javaandroidapicameracapture

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类开发工具
定价开源

> 相关工具

V
VS Code
流行的开源代码编辑器
G
Git
分布式版本控制系统
V
Vite
下一代前端构建工具