[java]
* 設置相機的預覽角度,在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();
}
}