首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > Android >

Android 技术总结(013)—— 设置相机的角度(api2.2以上的版本)

2012-09-07 
Android 技术总结(013)—— 设置相机的角度(api2.2以下的版本)/*** 设置相机的预览角度,在2.2以上可以直接使

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();        }    }


热点排行