【发布时间】:2014-10-31 14:02:30
【问题描述】:
当我创建 TAKE PHOTO 隐式意图时,会正确显示一个意图选择器窗口。不幸的是,它显示包名称而不是应用程序名称。知道我做错了什么吗?谢谢。
一切正常(意图、相机应用、返回到 onActivityResult 的图像……)。 如果只有一个相机应用程序 - 不显示选择,直接调用相机应用程序(正确)。 我安装的相机应用程序是:默认的安卓相机,谷歌相机。 在 3 款不同的三星手机上进行了测试。
private void dispatchTakePictureIntent() {
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
// Ensure that there's a camera activity to handle the intent
if (takePictureIntent.resolveActivity(getActivity().getPackageManager()) != null) {
// Create the File where the photo should go
File photoFile = null;
try {
photoFile = createImageFile();
} catch (IOException ex) {
Log.e(PoiDetailGalleryFragment.class.getSimpleName(), "Error occurred while creating the File", ex);
}
// Continue only if the File was successfully created
if (photoFile != null) {
Uri fileUri = Uri.fromFile(photoFile);
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri);
startActivityForResult(takePictureIntent, REQUEST_PHOTO_CAPTURE);
}
}
}
【问题讨论】:
-
会不会是语言问题?如果切换到英文用户界面,这还会显示包名吗?
标签: android android-intent camera package-managers