1

看到了解决方法,但是我曾经工作过,曾经不在线。我不知道是什么。

   int resultCode = -1, Intent data = null

拍照,经常搞定。

private void takePicture() {
        Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
        File photoFile = new File(Environment.getExternalStorageDirectory(), StartMenuActivity.DIR_NAME + "/" + travelDirName
                + "/" + travelDirName + "_" + poisArray.size() + ".jpg");
        cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photoFile));

        imageOrVideoUri = Uri.fromFile(photoFile);

        startActivityForResult(cameraIntent, CAMERA_REQUEST_PICTURE);
    }


@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {

        if ((resultCode == RESULT_OK)&&(data != null)) {
            if (requestCode == CAMERA_REQUEST_PICTURE) {
                createThumbnail();
                addPoi(PICTURE_POI);
            }
            if (requestCode == CAMERA_REQUEST_VIDEO) {
                addPoi(VIDEO_POI);
            }
            // Uri selectedUri = imageOrVideoUri;
            // Bitmap photo = (Bitmap) data.getExtras().get("data");
            // imageView.setImageBitmap(photo);
        } else {
            Toast.makeText(TravelMapActivity.this, R.string.poi_add_error, Toast.LENGTH_LONG).show();
        }
}

怎么修?谢谢。

4

2 回答 2

0

尝试这个,

protected void TakePhoto() {

        Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");

        File photo = new File(Environment.getExternalStorageDirectory()
                + "/LiveChat", "IMG_temp.jpg");
        System.gc();
        intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photo));
        imageUri = Uri.fromFile(photo);
        startActivityForResult(intent, 1);

}

  protected void onActivityResult(int requestcode, int resultcode, Intent data) {

        if (resultcode == RESULT_OK) {
            System.gc();
            switch (requestcode) {
            case 0:

         //ADD YOUR STUFF
                    }

        } else {
            Toast.makeText(getApplicationContext(), "No Image Selected",
                    Toast.LENGTH_SHORT).show();
        }

}
于 2013-02-21T13:00:36.110 回答
0

因此,这里的问题是您正在指定将照片写入相机意图的 URI。如果您提供 URI,则默认功能是不提供缩略图 - 因为您已经知道图像的位置。在您的活动结果中,只需使用 URI 来检索您的图像。关于这个问题有几个相关的帖子。

于 2014-01-21T16:32:46.493 回答