I'm trying to access the front facing camera through the Camera2 API using an actual device
the problem occurs when trying to
cameraManager.openCamera(..,..,..)
try {
CameraCharacteristics characteristics = manager.getCameraCharacteristics(mCameraID);
if (!mCameraOpenCloseLock.tryAcquire(2500, TimeUnit.MILLISECONDS)) {
throw new RuntimeException("Time out waiting to lock camera opening.");
}
manager.openCamera(mCameraID, mStateCallback, mBackgroundHandler);
} catch (CameraAccessException e) {
Log.e("mr", "OpenCamera - Camera Access Exception");
} catch (IllegalArgumentException e) {
Log.e("mr", "OpenCamera - Illegal Argument Exception");
} catch (SecurityException e) {
e.printStackTrace();
Log.e("mr", "OpenCamera - Security Exception:");
} catch (InterruptedException e) {
Log.e("mr", "OpenCamera - Interrupted Exception");
}
the Cameramanager says
I/CameraManagerGlobal: Connecting to camera service
which is coming from this CameraManager.java function
private void connectCameraServiceLocked() {
// Only reconnect if necessary
if (mCameraService != null) return;
Log.i(TAG, "Connecting to camera service");
Then my GLSurfaceView remains blank
AndroidMainfest.xml
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.google.android.permission.PROVIDE_BACKGROUND" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
P.S:
I'm using this example Render camera preview using OpenGL ES 2.0 on Android API 21 or higher
I've ended with changing the Sony Xperia Z5 premium to another device and it worked perfectly. it looks like that Sony is facing some problems with the new API as i saw in the following link:
there might be a work around but anyway i'm making an application for specific purpose i don't want it to be working on all devices