Android Camera autofocus when user holds camera still

I'm sure most of you have used an android phone before and taken a picture. Whenever the user changes the mobile phone's position and holds it steady, the camera focusses automatically. I'm having a hard time replicating this in my app. The autofocus() method is being called only once when the application is being launched. I have been searching for a solution these past 3 days and while reading the google documentation I stumbled upon the sensor method calls (such as when the user tilts the mobile forwards or backwards). I could use this API to achieve what I need but it sounds too dirty and too complicated. I'm sure there's another way around it.

All examples on the internet which I have found only focus when the user presses the screen or a button. I have also gone through several questions on SO to hopefully find what I am looking for but I was unsuccessful. I have seen this question and that String is not compatible with my phone. For some reason the only focussing modes which I can use is fixed and auto.

I was hoping someone here would shed some light on the subject because I am at a loss.

Thankyou very much for your time.

Answers


Yes, camera.autoFocus(callback) is a one-time function. You will need to call it in a loop to have it autofocus continuously. Preferably you would have a motion detection via accelerometer or compass to detect when camera is moved.


Since API 14 you can set this parameter

http://developer.android.com/reference/android/hardware/Camera.Parameters.html#FOCUS_MODE_CONTINUOUS_PICTURE


Need Your Help

Drupal 7 How to override page.tpl for specific content type?

drupal drupal-7 drupal-theming

I wanted to override page.tpl.php for specific content type.

How to get control value after Javascript refresh

c# javascript asp.net webforms code-behind

I have a page that has a popup modal window and the modal returns a value to the page and then refreshes it. I need to be able to get the value in the code-behind of the page when it is refreshed b...