PackageManager pm = getPackageManager();
boolean frontCam, rearCam;
//It would be safer to use the constant PackageManager.FEATURE_CAMERA_FRONT//but since it is not defined for Android 2.2, I substituted the literal valuefrontCam = pm.hasSystemFeature("android.hardware.camera.front");
rearCam = pm.hasSystemFeature(PackageManager.FEATURE_CAMERA);

PackageManager pm = getPackageManager();
if (pm.hasSystemFeature(PackageManager.FEATURE_CAMERA)) {
// Here if you get Camera Do you work LikeIntent i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
i.putExtra(MediaStore.EXTRA_OUTPUT,MyFileContentProvider.CONTENT_URI);
startActivityForResult(i, CAMERA_RESULT);
} else {
Toast.makeText(getBaseContext(), "Camera is not available",Toast.LENGTH_LONG).show();
}

Coding smarter using AI

"With so much code out there, many of the problems developers face are already solved. Codota trains on open source code and automatically completes best practice code in the IDE"