Using this piece of code is suggested and it states
Notice that the startActivityForResult() method is protected by a condition that calls resolveActivity(), which returns the first activity component that can handle the intent. Performing this check is important because if you call startActivityForResult() using an intent that no app can handle, your app will crash. So as long as the result is not null, it's safe to use the intent.
Code:
private void dispatchTakePictureIntent() {
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
startActivityForResult(takePictureIntent, REQUEST_IMAGE_CAPTURE);
}
}
It works fine, but NOT on an Alcatel device running 4.2.2. I get the ELSE
message with my toast "Cannot use camera..."
How is this possible if a device has the camera?
What should I do now? How to handle this use case - obviously I have to rely that some devices with the camera will report "cannot use camera", detect that those devices have camera and then use it?!
The documentation or SO questions say nothing about the ELSE case.