How to set Android camera orientation properly?
来源:互联网 发布:淘宝发布宝贝多种口味 编辑:程序博客网 时间:2024/04/29 00:48
This solution will work for all versions of Android. You can use reflection in Java to make it work for all Android devices:
Basically you should create a reflection wrapper to call the Android 2.2 setDisplayOrientation, instead of calling the specific method.
The method:
protected void setDisplayOrientation(Camera camera, int angle){ Method downPolymorphic; try { downPolymorphic = camera.getClass().getMethod("setDisplayOrientation", new Class[] { int.class }); if (downPolymorphic != null) downPolymorphic.invoke(camera, new Object[] { angle }); } catch (Exception e1) { }}
And instead of using camera.setDisplayOrientation(x) use setDisplayOrientation(camera, x) :
if (Integer.parseInt(Build.VERSION.SDK) >= 8) setDisplayOrientation(mCamera, 90); else { if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { p.set("orientation", "portrait"); p.set("rotation", 90); } if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { p.set("orientation", "landscape"); p.set("rotation", 90); } }
- How to set Android camera orientation properly?
- How to close resources properly
- How to properly unblock libusb_bulk_transfer
- How To Properly Set SVN svn:externals Property In SVN Command Line
- understanding positions and screen resolution, how to properly set position of object?
- How to properly convert SecureString to String
- camera orientation
- how to display chinese character properly
- How to properly address PHP_Incomplete_Class issue
- [Android Camera]关于Android Camera Orientation的一些总结
- Android double framebuffer(how to set)
- how to set android build type
- Correct Smartphone Video Orientation and How To Rotate iOS and Android Videos with ffmpeg
- qualcomm How to enable camera logs on Android builds?
- How to use Android MediaCodec encode Camera data(YUV420sp)
- How to set vim
- How to specify the orientation for an activity ?
- Android 手机Camera Orientation问题的深入研究
- hangcheck-timer模块
- LCD调色板
- 激活脑细胞——两人猜数问题
- c++编程:编写程序,任意输入一个字符串,将其中的最大字符放在字符串的第二个
- 交换机数据预处理系统之数据排序分析
- How to set Android camera orientation properly?
- 数据库 分表 意义、实现
- 纪念那些死去的青春细胞
- 体味AXIS开发web service
- python学习第七章
- BAK
- TempData、ViewData和ViewBag异同
- axis支持三种web service的部署和开发
- Android数据存储机制