Hai I am new to the Android. I am using Android4 sdk. I can't enable webcam in Android emulator. Can anyone tell how enable it. Thanks.
Asked
Active
Viewed 2.4k times
19
-
1@Tim you can use a camera on the emulator. This is a feature that was added to the Android SDK. However, I've never used it myself. – ThomasW Aug 08 '12 at 03:04
-
2This answer probably has what you're looking for: http://stackoverflow.com/a/8443673/211292 – ThomasW Aug 08 '12 at 03:09
2 Answers
26
There is a way to get this working use the Android Virtual Device Manager. You need to edit your AVD so that in the hardware section either "Configures camera facing front" or "Configures camera facing back" are available. One, but not both, of the values for these properties should be set to "webcam0" (or whatever is available). Then start your virtual device and use your webcam as an emulated camera.
If you have both properties set to "webcam0" then you'll get a warning when you start up the virtual device and the front/back control won't be available in the camera app.

ThomasW
- 16,981
- 4
- 79
- 106
-
I am setting "Configures camera facing front: webcam0". But if I check the front camera available in emulator, it returns false. Here the frontcam returns false and rearCam returns true.(i.e) PackageManager pm = getPackageManager(); frontCam = pm.hasSystemFeature("android.hardware.camera.front"); rearCam = pm.hasSystemFeature(PackageManager.FEATURE_CAMERA); What may be the problem? – Manoj Mar 20 '13 at 13:25
-
@Manoj I don't know what the problem might be. Tell us more about your AVD settings (target, CPU/ABI, etc.). – ThomasW Mar 21 '13 at 00:34
-
@ThomasW thanks for the reply. I have attached my AVD screenshots in the following post : http://stackoverflow.com/questions/15522686/android-camera-facing-front-not-working-in-emulator – Manoj Mar 21 '13 at 03:21
-
2I had webcam0 set for front and back which caused the issue. I set the back to webcam0 only and it worked. thanks ```emulator: WARNING: Camera name 'webcam0' is not found in the list of connected cameras. Use '-webcam-list' emulator option to obtain the list of connected camera names. ``` – Martin Naughton Jun 26 '20 at 10:18
6
Use emulator help to explore the available options
$ emulator -help 2>&1 | grep cam
-camera-back <mode> set emulation mode for a camera facing back
-camera-front <mode> set emulation mode for a camera facing front
-webcam-list lists web cameras available for emulation
and for example, use -webcam-list
to list the recognized cameras
$ emulator -webcam-list @4.1
List of web cameras connected to the computer:
Camera 'webcam0' is connected to device '/dev/video0' on channel 0 using pixel format 'YUYV'
to see the emulation options for cameras
$ emulator -camera-front help @4.1
emulator: ERROR: Invalid value for -camera-front <mode> parameter: help
Valid values are: 'emulated', 'webcam<N>', or 'none'

Diego Torres Milano
- 65,697
- 9
- 111
- 134
-
I got it working using the available camera in my avd config.ini file, lines: hw.camera.back=webcam0 hw.camera.front=none – Marco C. Nov 02 '15 at 15:48