How to detect no of camera's available in android device? and also if the device has front camera how to use it?
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.
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.
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.
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.
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.
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.
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:
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.
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;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With