My App built with Codename One features a Camera preview. I need to resort to the Native Interface implementation (so far Android) to show this preview. On some (older) Android devices I also need to call Camera.autofocus(AutofocusCallback) to make a sharp preview.
Android studio suggests me to use lambda expression to define the callback :
mCamera.autoFocus((b, camera) -> Log.d(TAG, "Camera may have focused"));
When I debug my project it wortks.
However when I copy paste this piece of code in Codename One native interface implementation, and send the Android build, the build process fails with the following error :
error: ')' expected
mCamera.autoFocus((b, camera) -> Log.d(TAG, "Camera may have focused"));
^
error: illegal start of expression
mCamera.autoFocus((b, camera) -> Log.d(TAG, "Camera may have focused"));
^
error: ';' expected
mCamera.autoFocus((b, camera) -> Log.d(TAG, "Camera may have focused"));
To get the build I have to convert the lambda into the more traditional :
mCamera.autoFocus(new Camera.AutoFocusCallback() {
@Override
public void onAutoFocus(boolean b, Camera camera) {
Log.d(TAG, "Camera may have focused");
}
});
Can't I use lambda in native interface implementation whereas it works flawlessly in Codename One code ?
Any help appreciated,