Reputation: 697
I set my emulator's back camera to "emulated". When I run my app, it returns a runtime exception saying "Cannot connect to camera service" on the line:
camera.open(-1);
Here is my manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.protoderma"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="9"
android:targetSdkVersion="16" />
<uses-permission
android:name="android.permission.FLASHLIGHT"
android:permissionGroup="android.permission-group.HARDWARE_CONTROLS"
android:protectionLevel="normal"
/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.CAMERA" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.protoderma.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Thank you.
Upvotes: 0
Views: 1635
Reputation: 13223
Without seeing more code it is hard to tell. But one potential problem I see is that you are passing a -1 to Camera.open();
. From the docs you see that the value passed should be always greater than 0 if there is a camera available. Ckeck the AVD's configuration to see if in the camera drop down you can select something else besides emulated (i.e. webcam0)
Upvotes: 1