android camera方向的确定 android中前后camera预览和拍照时方向是根据什么确立的?还有横或竖着拿手机时的方向? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 private void setDisplayOrientation(Context context){ int rotation = ((Activity) context).getWindowManager() .getDefaultDisplay().getRotation(); int degree = 0; switch (rotation) { case Surface.ROTATION_0: degree = 0; break; case Surface.ROTATION_90: degree = 90; break; case Surface.ROTATION_180: degree = 180; break; case Surface.ROTATION_270: degree = 270; break; } int result; CameraInfo info = new CameraInfo(); //Camera.getCameraInfo(mBackCameraId, info); Camera.getCameraInfo(0, info); if(info.facing == CameraInfo.CAMERA_FACING_FRONT){ result = (info.orientation + degree) % 360; result = (360 - result) % 360; }else{ result =(info.orientation - degree + 360 ) % 360; } mCamera.setDisplayOrientation(result); Log.v("shenwenjian","result:"+result); pictureOrientation = result; } Camera的setDisplayOrientation方法注解上有现成代码可用,和2楼的方法一样,楼主多看API 关于照片预览的方向 是exif 信息的事情。你可以google一下 android exif 就OK了 Android如何屏蔽Home键 请各位大牛给点意见,小弟真的很困惑 请教大家一个Scroller的问题 android如何连接远程服务器的数据库? 有代码吗?请帮忙? 怎么回事? Android 在程序里启动一个已安装的程序 如何创建一个不会阻塞UI的线程??? 想实现微信那样的编辑信息界面,怎么做? Google Maps API V3 和 V2有什么区别? 为什么这个字符串前面有一个小方块 singleInstance下切换时会出现黑屏。 android会限制播放flash访问视频吗?
int rotation = ((Activity) context).getWindowManager()
.getDefaultDisplay().getRotation();
int degree = 0;
switch (rotation) {
case Surface.ROTATION_0: degree = 0; break;
case Surface.ROTATION_90: degree = 90; break;
case Surface.ROTATION_180: degree = 180; break;
case Surface.ROTATION_270: degree = 270; break;
}
int result;
CameraInfo info = new CameraInfo();
//Camera.getCameraInfo(mBackCameraId, info);
Camera.getCameraInfo(0, info);
if(info.facing == CameraInfo.CAMERA_FACING_FRONT){
result = (info.orientation + degree) % 360;
result = (360 - result) % 360;
}else{
result =(info.orientation - degree + 360 ) % 360;
}
mCamera.setDisplayOrientation(result);
Log.v("shenwenjian","result:"+result);
pictureOrientation = result;
}