QR コード リーダーを開く前に、デバイスにカメラがあるかどうかを確認したいと考えています。
次のコードがあります。
public boolean checkDeviceCompatibility() {
PackageManager pm = context.getPackageManager();
if (pm.hasSystemFeature(PackageManager.FEATURE_CAMERA_ANY)) {
if (pm.hasSystemFeature(PackageManager.FEATURE_CAMERA)) {
return true;
} else {
// use front camera
Toast.makeText(
context,
"This device does not have a back camera so it has automatically reverted to the front camera",
Toast.LENGTH_SHORT).show();
return true;
}
} else {
util.displayErrorDialog(
context,
"This device does not have any cameras and therefore cannot make use of the QR Code feature.");
return false;
}
}
しかし、2 台のカメラを搭載した Galaxy S3 でこのコードをデバッグ モードで実行すると、. 最初の if ステートメントは false を返します。
これはなぜですか?