0

I am using a Xiaomi RedMi running Android 4.4.4. I am using the demo project as a reference for my DemoCameraFragment. When the camera starts up the first time, isAutofocusAvailable() returns false. After taking the first pic in SingleShotMode, I click on my "take next pic button" in which I call restartPreview(). For some reason, isAutofocusAvailable() now returns true and I can call autofocus successfully.

Now when I call getFlashMode(), when my app starts I get a Null Pointer Exception(Which I think occurs on the camera object). However, after I take the first pic and click on the "take next pic" button"( I call restartPreview() here), getFlashMode() no longer gives me a null pointer exception.

What exactly am I missing out setup-wise? I am using Android Annotations so my first call to both autofocus and getFlashMode is in @AfterViews annotated function. Why are Autofocus and getFlashMode not working for the first call?

Rohan
  • 593
  • 7
  • 22
  • "What exactly am I missing out setup-wise?" -- I have no idea, in part because I cannot see your code. Run the demo app. If the demo app exhibits similar problems on this device, then there is some incompatibility between the library and the device. If, OTOH, the demo app is working properly, then the issues are tied more closely to your code. – CommonsWare Aug 02 '15 at 10:58
  • isAutofocusAvailable and getFlashModes only return true after I call restartPreview once I have taken a photo and I click my "take next pic" button. – Rohan Aug 08 '15 at 19:50

1 Answers1

0
kotlin

cameraView.setOnClickListener{
    cameraView.autoFocus()
}
cui cui
  • 71
  • 5