确定Kindle是否存在相机

时间:2013-11-28 19:20:34

标签: android camera android-2.2-froyo kindle-fire kindle

我正在尝试确定特定的Android设备是否有相机。 android.hardware.Camera.open()州的文档

创建一个新的Camera对象以访问设备上的第一个后置摄像头。如果设备没有后置摄像头,则返回null。

我正在测试的Kindle(第一代我相信)没有任何相机,但open()正在返回非null。这是为什么?也许是因为亚马逊运行Android的分叉版本有不同的行为?还有另一种方法可以确定设备是否有摄像头吗?

1 个答案:

答案 0 :(得分:1)

也许这可以帮到你

/**
 * Determines if the current device can handle an image capture action.
 * @return true if the device can handle an image capture action. False if it cannot.
 */
protected boolean canHandleCameraIntent() {
  final Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
  final List<ResolveInfo> results = getPackageManager().queryIntentActivities(intent, 0);
  return (results.size() > 0);            
}

https://developer.amazon.com/sdk/fire/specifications.html

的更多内容

<强>更新

我不能为你测试,但我认为这也可以帮助你

http://developer.android.com/reference/android/content/pm/PackageManager.html

PackageManager.hasSystemFeature(PackageManager.FEATURE_CAMERA_ANY);
相关问题