https://kotlinlang.org logo
#android
Title
# android
s

sathawale27

05/10/2020, 1:44 PM
Hey, anyone has any idea about creating a tablet emulator without a built-in hardware camera feature. So, I could test the application for my workflow.
l

luke

05/11/2020, 10:48 AM
I think you can do that in the AVD Manager by selecting "Create Hardware Profile" https://developer.android.com/studio/run/managing-avds#createhp
s

sathawale27

05/11/2020, 10:54 AM
Thanks for your response. Actually, I was able to create an emulator without built-in camera, but the thing is whenever I check whether the camera feature is supported or not for such emulator, then it results in giving the true response everytime. Even if the camera feature is not supported.
l

luke

05/11/2020, 11:00 AM
What function are you using to check?
s

sathawale27

05/11/2020, 11:05 AM
packageManager.hasSystemFeature(PackageManager.FEATURE_CAMERA) It detects whether the device support camera feature or not. In my case it returns true even if I ran the application on emulator that doesn't have built-in camera feature
l

luke

05/11/2020, 11:39 AM
I think you'd want to call this function and wrap it in a try/catch: https://developer.android.com/reference/android/hardware/camera2/CameraManager#getCameraIdList()
s

sathawale27

05/11/2020, 11:56 AM
Yeah, I thought of it and tried that too. It also detects 2 cameras for such emulators.
Thanks @luke. It worked by using the CameraManager API. I was using the old emulator that has camera, so got that result. Thanks for you response.
l

luke

05/11/2020, 1:21 PM
Nice one. I should have read your message earlier, I just knocked up a sample 😄
s

sathawale27

05/11/2020, 1:24 PM
Oops! Btw thanks for your efforts.
👍 1
l

luke

05/11/2020, 1:29 PM
👍🏻 1