捕获图像不会显示

时间:2016-08-09 20:45:35

标签: android android-image

我有一个按钮,可以让我拍摄或选择4张照片,并立即在各自的ImageView中显示。这意味着我可以选择拍摄第一张照片,选择第二张照片,选择第三张照片拍摄第四张照片;等等。

我的代码有效,因此四个URI存储在ArrayList中并从那里拉出来进行显示。奇怪的是,只有我从画廊中选择的图片出现了。即我从画廊中选择了我的第一张照片并拍摄了另外三张照片;只有第一次显示。我已经调试过了,我成功地从{"""图片。更重要的是,这些图片也可以在我的画廊中找到。

请查看我的代码,看看我哪里出错了。

URI

takePictureIntent()

private void dispatchTakePictureIntent() { for(int i = 0; i < 4; i++) { Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); if (takePictureIntent.resolveActivity(getPackageManager()) != null) { // Create the File where the photo should go File photoFile = null; try { photoFile = createImageFile(); outputFileUri = Uri.fromFile(photoFile); } catch (IOException ex) { Log.w("error","IOException"); }catch (NullPointerException nullEx) { Log.w("error","NullPointerException"); } // Camera. final List<Intent> cameraIntents = new ArrayList<Intent>(); final Intent captureIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); final PackageManager packageManager = getPackageManager(); final List<ResolveInfo> listCam = packageManager.queryIntentActivities(captureIntent, 0); for (ResolveInfo res : listCam) { final String packageName = res.activityInfo.packageName; final Intent intent = new Intent(captureIntent); intent.setComponent(new ComponentName(res.activityInfo.packageName, res.activityInfo.name)); intent.setPackage(packageName); intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photoFile)); cameraIntents.add(intent); } // Filesystem. final Intent galleryIntent = new Intent(); galleryIntent.setType("image/*"); galleryIntent.setAction(Intent.ACTION_OPEN_DOCUMENT); // Chooser of filesystem options. final Intent chooserIntent = Intent.createChooser(galleryIntent, "Select Source"); // Add the camera options. chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, cameraIntents.toArray(new Parcelable[cameraIntents.size()])); if(id.equals(HAPPY_ID)) startActivityForResult(chooserIntent, REQUEST_HAPPY_PHOTO); if(id.equals(SURPRISED_ID)) startActivityForResult(chooserIntent, REQUEST_SURPRISED_PHOTO); if(id.equals(AFRAID_ID)) startActivityForResult(chooserIntent, REQUEST_AFRAID_PHOTO); if(id.equals(UPSET_ID)) startActivityForResult(chooserIntent, REQUEST_UPSET_PHOTO); if(id.equals(SAD_ID)) startActivityForResult(chooserIntent, REQUEST_SAD_PHOTO); } } }

onActivityResult()

0 个答案:

没有答案