java - An error occurred while connecting to camera: 0 --- Fail to connect to camera service -


i have phone specific problem when open camera on 1 particular nexus 5. an error occurred while connecting camera: 0 --- fail connect camera service error. on @ least dozen other phones works fine. other apps use camera on nexus 5 not crashing (indicating not apps can't access camera, mine).

there number of other questions on , have tried of them. talk missing permissions, , making sure camera destroyed after use.

to clear manifest requests , uses camera properly:

<uses-permission android:name="android.permission.camera" /> <uses-feature android:name="android.hardware.camera" /> <uses-feature android:name="android.hardware.camera2" /> 

and releasing camera when destroying:

public void releasecamera() {     if (_camera != null)     {         _camera.stoppreview();         _camera.setpreviewcallback(null);         _camera.release();         _camera = null;     }      _surfaceholder.removecallback(this); } 

can think of reason what-so-ever getting this. have suspicion theres sort of bug because using camera , not camera2 wild guess. reading updates api 6.0 there section on camera says:

in release, model accessing shared resources in camera service has been changed previous “first come, first serve” access model access model high-priority processes favored.

again without re-writing entire app use camera2 (not option) can't what's going on.

here code open camera (and works on every other phone except nexus 5)

private void setinitialcamera() {     try     {         if (_isbackfacing == true)         {             _camera = camera.open(0);         } else         {             _camera = camera.open(1);         }     } catch (runtimeexception e)     {         log.d("runtime exception","error " + e);         e.printstacktrace();     } catch (exception e)     {         log.d("camera error: ", " android unable tell error was");         e.printstacktrace();     } } 

so looks culprit has something 6.0.1 update phone went through.

while didn't happen on other phones, did on failing nexus 5.

what happened 6.0.1 update allows users set individual permissions app. somehow persmission camera toggled off. turning on fixed issue.

to there go settings -> apps -> [app name] -> permissions

enter image description here


Comments

Popular posts from this blog

java - pagination of xlsx file to XSSFworkbook using apache POI -

Unlimited choices in BASH case statement -

apache - How do I stop my index.php being run twice for every user -