I'm seeing a few different things online so I wanted to make sure I was doing it correctly:
To check if a phone has a camera:
PackageManager pm = context.getPackageManager();
if (pm.hasSystemFeature(PackageManager.FEATURE_CAMERA)) {
//proceed
}
But I also see from http://developer.android.com/training/camera/photobasics.html
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
PackageManager pm = context.getPackageManager();
if (takePictureIntent.resolveActivity(pm) != null) {
//proceed
}
I know the first one is "correct" for verifying that the camera exists or not, but what is the second one doing exactly? Is it a good idea to actually check for both conditions before proceeding, or does it suffice to just check one or the other?
According to http://developer.android.com/reference/android/content/pm/PackageManager.html#resolveActivity%28android.content.Intent,%20int%29 it says that resolveActivity
"Determine the best action to perform for a given Intent" but I don't really know what that entails. Is this another way to "check for the camera"?