2011-10-19 2 views
4

세로 모드에서 카메라 미리보기를 사용하는 데 문제가 있습니다. 나는 그것에 대해 여러 기사를 읽었으며 나는 다음과 같은 코드를 가지고 해결했다 :안드로이드 카메라 setDisplayOrientation : 갤럭시 탭의 이상한 동작

Display display = ((CaptureActivity)context).getWindowManager().getDefaultDisplay(); 
int width = display.getWidth(); 
int height = display.getHeight(); 

if (Integer.parseInt(Build.VERSION.SDK) >= 8) { 
    setDisplayOrientation(camera, 90); 
}else{ 
    Camera.Parameters parameters = camera.getParameters(); 
    parameters.set("orientation", "portrait"); 
    camera.setParameters(parameters); 
} 
로 setDisplayOrientation()가 정의되어

: 나는 갤럭시 탭과이 코드를 시도 자

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) { 
    } 
} 

실패한.

if (height == 1024 && width == 600) { 
    Camera.Parameters parameters = camera.getParameters(); 
    parameters.set("orientation", "portrait"); 
    parameters.setRotation(90); 
    camera.setParameters(parameters); 
} 

지금 내 두 가지 질문은 다음과 같습니다 : 나는 다음과 같은 코드를 사용하여 (시도 및 오류 방식)을 해결 갤럭시 탭은 2.2 버전이 동시에 같은 문제가 왜

1)

2)이 문제에 대한 더 나은 해결책이 있습니까?

시간 내 주셔서 감사합니다.

+0

이 솔루션을 확인한 적이 있습니까? http://stackoverflow.com/questions/3841122/android-camera-preview-is-sideways/5110406#5110406 ​​ –

+0

예, 행운을 ... 고맙습니다. –

+0

@DimitrisMakris 당신은 이것을위한 해결책을 얻었습니까? 부디! 공유, 나는 똑같은가? – swiftBoy

답변

0

디스플레이 방향을 설정하기 위해 공식 docs을 체크하고 거기에서 90도 하드 코드하지 마십시오.

관련 문제