资源简介
android调用camera时,可以自己写一个activity,赋上相关参数,打开前camera就可以了;
需要申请的permission,在AndroidManifest.xml中添加:
主要功能,打开前camera
private Camera openFrontFacingCameraGingerbread() {
int cameraCount = 0;
Camera cam = null;
Camera.CameraInfo cameraInfo = new Camera.CameraInfo();
cameraCount = Camera.getNumberOfCameras();
for (int camIdx = 0; camIdx < cameraCount; camIdx++) {
Camera.getCameraInfo(camIdx, cameraInfo);
if (cameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
try {
cam = Camera.open(camIdx);
mCurrentCamIndex = camIdx;
} catch (RuntimeException e) {
Log.e(TAG, "Camera failed to open: " + e.getLocalizedMessage());
}
}
}
return cam;
}
根据打开时的横竖屏方向来调整preview角度
//根据横竖屏自动调节preview方向,Starting from API level 14, this method can be called when preview is active.
private static void setCameraDisplayOrientation(Activity activity,int cameraId, Camera camera)
{
Camera.CameraInfo info = new Camera.CameraInfo();
Camera.getCameraInfo(cameraId, info);
int rotation = activity.getWindowManager().getDefaultDisplay().getRotation();
//degrees the angle that the picture will be rotated clockwise. Valid values are 0, 90, 180, and 270.
//The starting position is 0 (landscape).
int degrees = 0;
switch (rotation)
{
case Surface.ROTATION_0: degrees = 0; break;
case Surface.ROTATION_90: degrees = 90; break;
case Surface.ROTATION_180: degrees = 180; break;
case Surface.R
代码片段和文件信息
/** Automatically generated file. DO NOT MODIFY */
package com.yxiaolv.camerasample;
public final class BuildConfig {
public final static boolean DEBUG = true;
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
....... 7658 2014-02-24 00:55 res\drawable-hdpi\ic_launcher.png
....... 3777 2014-02-24 00:55 res\drawable-mdpi\ic_launcher.png
....... 12516 2014-02-24 00:55 res\drawable-xhdpi\ic_launcher.png
....... 24777 2014-02-24 00:55 res\drawable-xxhdpi\ic_launcher.png
文件 1350 2014-06-04 15:43 res\layout\activity_main.xm
文件 439 2014-06-04 16:29 res\menu\main.xm
....... 213 2014-02-24 00:55 res\values\dimens.xm
文件 273 2014-06-04 16:30 res\values\strings.xm
....... 680 2014-02-24 00:55 res\values\st
....... 196 2014-02-24 00:55 res\values-sw600dp\dimens.xm
....... 269 2014-02-24 00:55 res\values-sw720dp-land\dimens.xm
....... 324 2014-02-24 00:55 res\values-v11\st
....... 381 2014-02-24 00:55 res\values-v14\st
文件 6712 2014-06-04 15:45 src\com\yxiaolv\camerasample\CameraActivity.java
文件 475 2014-06-04 15:00 .classpath
文件 848 2014-06-04 15:00 .project
文件 1164 2014-06-04 15:45 AndroidManifest.xm
....... 51394 2014-02-24 00:55 ic_launcher-web.png
....... 781 2014-02-24 00:55 proguard-project.txt
文件 563 2014-06-04 15:00 project.properties
....... 392 2014-02-24 00:55 README.md
文件 166 2014-06-04 17:10 gen\com\yxiaolv\camerasample\BuildConfig.java
文件 2793 2014-06-04 17:10 gen\com\yxiaolv\camerasample\R.java
....... 627582 2014-02-24 00:55 libs\android-support-v4.jar
目录 0 2014-06-04 15:43 src\com\yxiaolv\camerasample
目录 0 2014-06-04 17:10 gen\com\yxiaolv\camerasample
目录 0 2014-06-04 15:44 src\com\yxiaolv
目录 0 2014-06-04 17:10 gen\com\yxiaolv
目录 0 2014-02-24 00:55 res\drawable-hdpi
目录 0 2014-06-04 15:00 res\drawable-ldpi
............此处省略22个文件信息
- 上一篇:java程序员顶岗实习
- 下一篇:face++API调用代码
相关资源
- android ListView显示和隐藏二级内容
- android TestUsb
- android 滑动选择日期jar包
- AndroidRClassGenerator
- android定时开关机或重启的代码
- Android wifi列表显示
- android书架效果,可以触底刷新
- 异常捕获或自动重启app
- Android图片涂鸦源码
- Android 在线播放器代码
- android-support-v4.jar解决了友盟反馈
- Android蓝牙串口传输心电数据画图的小
- Java 、Android实现MP4裁剪功能
- 老罗Android开发视频教程合集.txt
- android手机的远程视频监控系统
- android手机防盗软件源代码
- Android greenDAO使用demo
- 高通android modem架构介绍
- android 6.0 可用 sqlite3 和so文件
- Android NFC Demo1
- Android 开发环境
- EspTouchAndroid_v0.3.4.3.apk
- 基于Android移动平台的客户关系管理系
- android贪食蛇源码游戏是基于重绘vie
- eclipse导入Android studio所需文件
- Android通过NFC读取IC卡
- Android开发工具ADT插件sqlitemanager_1.0.
-
Android ijkpla
yer播放rtsp直播流 -
eclipse-java-google-st
yle - Android仿iPhone滚动控件源码
评论
共有 条评论