要解决此问题,可以尝试以下几种方法:
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); startActivityForResult(intent, CAMERA_REQUEST);
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == CAMERA_REQUEST && resultCode == RESULT_OK) { Bitmap bitmap = (Bitmap) data.getExtras().get("data"); imageView.setImageBitmap(bitmap); } }
实现了上述方法后,您的应用程序不应该再在打开相机意图后崩溃。