Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect no of camera's available in android device? and also if the device has front camera how to use it?

Tags:

android

How to detect no of camera's available in android device? and also if the device has front camera how to use it?

like image 795
sureshmenon13196 Avatar asked Apr 08 '11 04:04

sureshmenon13196


People also ask

How can you detect hidden cameras?

Here are 6 simple ways you can do to detect a hidden camera:Check for any unusual objects in the room. Turn off the Lights in Your Room to Spot Hidden Night Vision Cameras. Use Your Mobile Phones to Locate Hidden CCTV Surveillance Cameras. Use a Professional Camera Detector or Sensor to Spot Hidden CCTV Cameras.

How can you detect hidden cameras on your phone?

One of the easiest ways to find hidden cameras is to use your cell phone. Simply download a hidden camera detector app and open it up. Then, scan the area for any cameras. The app will alert you if any are found.

How do I know if my Android has a camera?

In Android, you can use PackageManager , hasSystemFeature() method to check if a device has camera, gps or other features. See full example of using PackageManager in an activity class.

How do I find the available camera on my Android device?

Apps running on Android 9 devices can discover every available camera by calling getCameraIdList (). An app should not assume that the device has only a single back camera or only a single front camera. For example, if your app has a button to switch between the front and back cameras, there may be more than one front or back camera to choose from.

Why is my front camera not working on my Android phone?

If the front camera still isn’t working, move to the next step. On the other hand, if it works, consider resetting app preferences to default values or even factory resetting your device. 3. Check app permissions This is beyond obvious but stranger things have happened.

Can Android phones detect hidden cameras and microphones?

Although not foolproof, it's possible to use your Android phone's camera and magnetometer sensor to detect hidden cameras and microphones or other listening devices. Some hidden cameras emit IR (infrared radiation) light, which isn't visible to the naked eye.

What is a camera in Android?

In Android, Camera is a hardware device that allows capturing pictures and videos in your applications. Follow this tutorial to easily understand how to use a camera in your own Android App. The Android framework provides the facility of working with Camera in two ways:


2 Answers

What I would suggest is similar to doc_180's answer, but should be able to detect both front and back facing cameras even for Froyo, though if I'm not mistaken, Froyo never supported front-facing cameras, so you'll always get a false response for frontCam on Froyo.

PackageManager pm = getPackageManager();
boolean frontCam, rearCam;

//Must have a targetSdk >= 9 defined in the AndroidManifest
frontCam = pm.hasSystemFeature(PackageManager.FEATURE_CAMERA_FRONT);
rearCam = pm.hasSystemFeature(PackageManager.FEATURE_CAMERA);

EDIT: Just realized this is a really, really old question. Oh well, hopefully it helps someone in the future.

like image 181
Kevin Coppock Avatar answered Oct 21 '22 10:10

Kevin Coppock


Use packagemanager to check if the device supports the Intent. In this case Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);

public static boolean isIntentAvailable(Context context, String action) {
    final PackageManager packageManager = context.getPackageManager();
    final Intent intent = new Intent(action);
    List<ResolveInfo> list =
            packageManager.queryIntentActivities(intent,
                    PackageManager.MATCH_DEFAULT_ONLY);
    return list.size() > 0;
}
like image 44
uncaught_exceptions Avatar answered Oct 21 '22 11:10

uncaught_exceptions