Android 技术总结(013)—— 设置相机的角度(api2.2以下的版本)
/** * 设置相机的预览角度,在2.2以上可以直接使用setDisplayOrientation * * @param orientation 相机的预览角度 */ private void setDisplayOrientation(int orientation) { Method setCameraDisplayOrientation; try { // 通过反射,获取相应的方法 setCameraDisplayOrientation = mCamera.getClass().getMethod( "setDisplayOrientation", new Class[] { int.class }); if (setCameraDisplayOrientation != null) { setCameraDisplayOrientation.invoke(mCamera, new Object[] { orientation }); } } catch (Exception e) { MobclickAgent.reportError( mContext, getResources().getString( R.string.umeng_error_set_display_orientation)); e.printStackTrace(); } }