Android 安卓:摄像头没有响应;“好的”;尝试保存图像时单击“保存”按钮

Android 安卓:摄像头没有响应;“好的”;尝试保存图像时单击“保存”按钮,android,image,camera,Android,Image,Camera,我是android新手,我正在尝试将代码的一部分用于保存使用默认android摄像头的应用程序拍摄的图像。我希望退出相机后,图像将显示在不同的活动中。现在,如果我不保存它,图像将在相机模式退出后显示。但是如果我也尝试保存它,相机根本不会退出,“OK”按钮也不会响应。 我正在尝试构建一个应用程序,它可以拍照并将其连接到电子邮件,然后将其与GPS位置数据一起发送。因此,交换机外壳的“发送消息”部分就是出于这个原因 public void onClick(View v) { // T

我是android新手,我正在尝试将代码的一部分用于保存使用默认android摄像头的应用程序拍摄的图像。我希望退出相机后,图像将显示在不同的活动中。现在,如果我不保存它,图像将在相机模式退出后显示。但是如果我也尝试保存它,相机根本不会退出,“OK”按钮也不会响应。 我正在尝试构建一个应用程序,它可以拍照并将其连接到电子邮件,然后将其与GPS位置数据一起发送。因此,交换机外壳的“发送消息”部分就是出于这个原因

    public void onClick(View v) {

    // TODO Auto-generated method stub
    switch (v.getId()) {

    case R.id.Picture:
        File file = new File(Environment.getExternalStorageDirectory().getPath() + "/My Images/" + "bhe_app" + ".jpg");
        Uri imageUri = Uri.fromFile(file);

        i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
        i.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);

        startActivityForResult(i, cameraData);

        break;

    case R.id.SendMessage:  //Sending message part 

        EditTextToString();

        EmailIntent = new Intent(android.content.Intent.ACTION_SEND);

        EmailIntent.putExtra(Intent.EXTRA_EMAIL,
                new String[] { "myEmail@gmail.com" });
        EmailIntent.putExtra(android.content.Intent.EXTRA_TEXT,
                MessageToBeReceived);
        EmailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "@"+Lattitude_data +"," +Longitude_data);

        // EmailIntent.setType("message/rfc822");
        EmailIntent.setType("image/jpeg");
        // EmailIntent.putExtra(Intent.EXTRA_STREAM, fileUri);

        startActivity(Intent.createChooser(EmailIntent,
                "Choose an Email client :"));
        break;

    }

}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    // TODO Auto-generated method stub
    super.onActivityResult(requestCode, resultCode, data);
    if (resultCode == RESULT_OK) {
        Bundle extras = data.getExtras();
        bmp = (Bitmap) extras.get("data");
        iv.setImageBitmap(bmp);
        //iv is an image view in an activity where I display the image taken.
    //bmp is defined as being Bitmap.
    //  final static int cameraData =0


    }
} 

您忘记创建您写入映像的目录。 在创建文件对象之前添加此行

File path = new File(Environment.getExternalStorageDirectory().getPath() + "/My Images/").
path.mkdirs();

您忘记创建您写入映像的目录。 在创建文件对象之前添加此行

File path = new File(Environment.getExternalStorageDirectory().getPath() + "/My Images/").
path.mkdirs();