You didn't say what actually goes wrong. Are you not getting the DPAD_CENTER event at all, is it not repeating the same as on a G1, or something else? One thing that looks a little suspicious is that in onKeyDown when it receives DPAD_CENTER, you set 'inited' to false, which would then prevent you from ever executing any of the other code in onKeyDown again.
On Sun, Jun 21, 2009 at 8:33 PM, shotwave <[email protected]> wrote: > > Hi, I have got a bunch of questions why image capture does not work > with the trackball click on HTC Magic. Here is the code, which works > on G1 phone > > private FocusCameraListener1 focusCameraListener1 = new > FocusCameraListener1(); > private FocusCameraListener2 focusCameraListener2 = new > FocusCameraListener2(); > > @Override > public boolean onKeyDown(final int keyCode, final KeyEvent event) { > if (inited) { > if (event.getRepeatCount() < 2) { > if (keyCode == KeyEvent.KEYCODE_FOCUS) { > > camera.autoFocus(focusCameraListener1); > return true; > } else if (keyCode == > KeyEvent.KEYCODE_CAMERA || keyCode == > KeyEvent.KEYCODE_DPAD_CENTER) { > inited = false; > > > if (focused) { > capture(); > } else { > > camera.autoFocus(focusCameraListener2); > } > > return true; > } > } > } > return super.onKeyDown(keyCode, event); > } > > private class FocusCameraListener1 implements ICameraListener { > @Override > public void onPictureTaken(final byte[] data) { > } > > @Override > public void onAutoFocus(final boolean success) { > if (success) { > afView.setImageResource(R.drawable.af); > focused = true; > } else { > afView.setImageBitmap(null); > focused = false; > } > } > } > > private class FocusCameraListener2 implements ICameraListener { > @Override > public void onPictureTaken(final byte[] data) { > } > > @Override > public void onAutoFocus(final boolean success) { > if (success) { > capture(); > } > } > } > > Basically what I am trying to do is to use the autofocus feature > whenever possible (if the user pressed the focus key or if the user > pressed the camera key). Once the autofocus was completed successfully > the camera will capture an image. > > I am out of ideas what could be wrong here, pls help > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---

