마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

현재 스마트폰의 카메라가 작동중인지 알수있는 Camera.메소드가 있나요?

0 추천
답변부탁드립니다.(__)
익명사용자 님이 2015년 4월 7일 질문

2개의 답변

0 추천

직접 테스트 해보진 않았으나 API 문서로는 CameraManager를 통해 알 수 있는 것 같습니다.

 

원문 : http://developer.android.com/reference/android/hardware/camera2/CameraManager.html#registerAvailabilityCallback(android.hardware.camera2.CameraManager.AvailabilityCallback, android.os.Handler)

 

public void registerAvailabilityCallback (CameraManager.AvailabilityCallback callback, Handler handler)

Added in API level 21

Register a callback to be notified about camera device availability.

Registering the same callback again will replace the handler with the new one provided.

The first time a callback is registered, it is immediately called with the availability status of all currently known camera devices.

Since this callback will be registered with the camera service, remember to unregister it once it is no longer needed; otherwise the callback will continue to receive events indefinitely and it may prevent other resources from being released. Specifically, the callbacks will be invoked independently of the general activity lifecycle and independently of the state of individual CameraManager instances.

 

Parameters
callback the new callback to send camera availability notices to
handler The handler on which the callback should be invoked, or null to use the current thread's looper.

 

callback으로 사용가능하다면  onCameraAvailable이 사용 불가하다면 onCameraUnavailable이 호출 될 겁니다

Gradler (109,780 포인트) 님이 2015년 4월 7일 답변
답변감사합니다. 사용가능하냐불가능하냐가 아니라 현재 카메라가 켜져있냐 꺼져있냐를 알고싶어요ㅠㅠ
0 추천
보통 Camera.open() 해서 에러가 나면 켜져있거나 고장난것으로 간주합니다.
nicehee (73,100 포인트) 님이 2015년 4월 7일 답변
...