Run an emulator without camera - java

I want to emulate an android device that has no in-built camera but I can't find a way to do this.
I have disabled the options for camera in the Android AVD Manager when creating a new emulator (and hardware), but the resulting emulator still has camera capabilities. I also tried using Genymotion emulator, but that doesn't even seem to have the option to disable camera.
Reason why:
I have this line in my manifest android:name="android.hardware.camera" that prevents a user that owns a device without camera from installing my app (Device not compatible). I want to add android:required="false" to it but that would mean I also have to implement some code for the case where the user accesses a camera function from my app while not having one on his device, and I need to test that.
Any suggestions are appreciated.

Try to switch Camera options Front and Back to None in device advanced settings.

Related

Camera intent open the camera app (only the first time)

Here is the context:
In my app, I need to capture images, that's why I use camera intent.
This feature works perfectly, but only if the camera app was already been opened once before
Indeed, this issue appears only on a new device, or a new emulator
Here is the problem:
When I want to capture an image, the native camera app just open, giving to me some hints to how take pictures. That's not the camera app IN my app, but the camera app alone. I need to close this camera app, back to my app, and trying again
When I visit the camera app at least one time in the device's life, there is no issue
Here is what I'm looking for:
I want this camera app open in my app, even if it's the first time
I use the classic and official way to captures images
https://developer.android.com/training/camera/photobasics
EDIT
I think the problem is because at the first time, the camera app asked for the location permission. So we need to open the intent without asking this permission, to keep the focus
When I want to capture an image, the native camera app just open, giving to me some hints to how take pictures.
There are ~26,000 Android device models. These ship with dozens, if not hundreds, of different pre-installed camera apps. The behavior of any of those apps on first run of that app will vary by app. Moreover, the decision of how those apps behave when they are first run is up to the developers of those apps, not you or me.
That's not the camera app IN my app, but the camera app alone
It is never "IN [your] app" if you are using ACTION_IMAGE_CAPTURE, as your question suggests that you are. It is always a third-party app, one of many pre-installed ones, or one of the user ones. And, again, the behavior of those apps are up to their respective developers.
I want this camera app open in my app, even if it's the first time
Sorry, but that is not under your control.

Android Emulator: Unable to start webcam to capture picture in emulator

I have created an armeabi API 21 emulator in the AVD manager in Android Studio, set it to use the webcam as a front camera, and launched it.
The problem is that it's not able to open it, as I'm getting this error:
emulator: ERROR: camera_device_start_capturing: VIDIOC_STREAMON on camera '/dev/video0' has failed: Timer expired
emulator: ERROR: _camera_client_query_start: Cannot start camera '/dev/video0' for NV21[640x480]: Inappropriate ioctl for device
How can I solve this?
The webcam works normally using other software. The operative system is Ubuntu 14.04.
In Android Studio, go to AVD Manager, click on edit (pencil) button in Actions. After that, in next appearing window, click on Advance settings, and then scroll down and in Camera options, select webcam for front and back.
To enable Camera in your Android Emulator, just add following highlighted code in your AVD’s config.ini file. You can find the config.ini file under your <userdirectory>/.android folder.
File: ~/.android/config.ini
hw.lcd.density=160<br>
skin.name=HVGA<br>
skin.path=platforms\android-9\skins\HVGA<br>
hw.cpu.arch=arm<br>
abi.type=armeabi<br>
vm.heapSize=24<br>
image.sysdir.1=platforms\android-9\images\<br>
hw.camera=yes<br>
sdcard.size=64M<br>
In case you don’t find the config.ini file or want to enable Camera support through Android SDK and AVD Manager do the following:
Open Android SDK and AVD Manager:
Add SD Card in AVD
In the SD Card setting, set the value for Size. To enable camera, the SD Card must be enabled in Emulator.
Add Camera Support in Hardware under AVD
Now under Hardware section, click New button to add Camera hardware. It will open following Dialog box. Select Camera support from the Property dropdown and click Ok.
Enable Camera Support in Hardware
The new hardware: Camera support is visible under Hardware section. Set its value to yes and save changes by pressing Edit AVD.
Save the changes and launch the emulator.
You can try to manually edit your AVD's configuration file under
~/.android/avd/yourAvdName/config.ini
by adding this line:
hw.camera=yes
UPDATE
You can try to specify the real resolution of your webcam:
hw.camera.maxHorizontalPixels=XXX
hw.camera.maxVerticalPixels=XXX
Keep in mind that the default value for maxHorizontalPixels is 640 and for maxVerticalPixels is 480, so chaning this values may help you to solve your issues.
I had a similar issue with a slightly different error message under OS X. I turned out that everything was ok but the emulator is crashing when the camera takes too much time to initialize.
I my case I ended up closing other applications and it worked. You may want to test in a more performant computer.
I had trouble getting the camera to work under the emulator (under linux), even after setting it up in AVD as instructed here. I was helped by noticing that the camera it was trying to use was /dev/video0, but the camera I wanted was /dev/video3. A quick swap...
mv /dev/video0 /dev/video4
mv /dev/video3 /dev/video0
...did the trick
Change /dev/video6 into /dev/video0

Programmatically mute an Android wearable

I programmatically want to mute the entire watch. So I wanted to do these things:
1. Mute to on , so go into non vibration mode. Will manufacturers be able to add sound capabilities to watches? Otherwise I would also have to add muting of sound...
2. Screen always on , to off. It's a system setting. Can I change it programmatically?
I already tried for point one to use the MediaManager:
AudioManager audioManager = (AudioManager)getSystemService(Context.AUDIO_SERVICE);
audioManager.setRingerMode(AudioManager.RINGER_MODE_SILENT);
I tried all other ringer modes also just to be sure and nothing seems to work and change anything in the emulator and on my real watch but nothing is doing the job...
A pebble watch has night or silent mode support... So I won't be that hard to do it on a wearable I thought.. Any ideas on this one?
Wear 5.0.1 has some ability! the SDK sample Watchface has a way to detect it. Look for WatchFaceService.INTERRUPTION_FILTER_NONE - RoundSparrow hilltx
from this question here: Android Wear detect "Mute"
Maybe with requestInterruptionFilter where fitler mode are:
INTERRUPTION_FILTER_ALL
NTERRUPTION_FILTER_NONE
INTERRUPTION_FILTER_PRIORITY

How to run camera dependent program on android Emulator

I made a few programs in which I need to capture pictures using notebook Camera and send it through email. THe problem is neither can I send an email nor I can capture pictures using camera through emulator. I have gone through some suggested solutions like "tomgibara" but like most of the people it is not working for me in case of camera. And I havent found any solution of sending email thorugh emulaotr cuz there is not option. I don't have android device to run these programs on that. Is there any way to solve this problem.
On my emulator, you can't use Camera or send mail, you'll either have to test it on the phone, tablet or something with android (Not emulator). with debug mode on, or just presume it works...

How do you enable a microphone input in the android emulator

I have been on a rough ride trying to do something using the Speech recognition on an android emulator.
Having finally installed the market place and the Google Voice Search app - I am so close to enabling my emulator to do what I want - recognize my speech. First I need to enable the emulator to record audio , or at least think that a microphone is present.
I believe adb used to have the -mic option - however I dont think it exists anymore.
Has anyone done this or can anyone shed some light on it.
have you seen this tutorial? see the comment:
You guys are not able to record sound
in emulator because the android
emulator doesn’t support it yet. This
code should only work on the phone.
Update
Now it is possible to record audio by android emulators, just need to enable it:
Extended controls (3 dots in emulator control bar) > Microphone > Virtual microphone uses host audio input
In 2021 there is an option in emulator settings to enable computer host microphone.
To On/Off the microphone of emulator, write the command in terminal of android studio.
for On microphone : adb emu avd hostmicon
for Off microphone: adb emu avd hostmicoff
hi try by enabling the audio recording support while creating the virtual device in emulator... While creating device go to hardware part and select new button. A dialog will appear in which select the property combo and select "Audio Recording Support" and give k and apply...
Hope it helps...
Let me know the output of it...
What version of Android is your Emulator running? I've had similar issues with audio in general when I try to run an Emulator with Android 2.2, which had no sound at all on Windows 7 32-bit. Still haven't been able to fix it, but when I swapped to an Android 2.3 emulator, the sound automatically worked. Maybe you could try this...

Categories

Resources