0

我已经在这里呆了 3 天了,但仍然没有运气。我正在尝试拍照,裁剪它,然后通过 Android 上的意图发送电子邮件。

到目前为止,我可以拍照并裁剪它。但是,当我尝试设置电子邮件部分时,只要我拍照,电子邮件意图就会立即弹出并且不允许我裁剪。(如果我点击 gmail,裁剪在后台)。

到目前为止,我已经尝试过:

        @Override
    public void onPictureTaken(byte[] arg0, Camera arg1) {

        //Bitmap bitmapPicture = BitmapFactory.decodeByteArray(arg0, 0, arg0.length);   



        OutputStream imageFileOS;
        try {
            imageFileOS = getContentResolver().openOutputStream(uriTarget);
            imageFileOS.write(arg0);
            imageFileOS.flush();
            imageFileOS.close();

            Toast.makeText(DigitalSignature.this, 
                    "Image saved: " + uriTarget.toString(), 
                    Toast.LENGTH_LONG).show();

            String[] recipients = new String[]{"digital.signature@lads.jetdelivery.com", "",};


            Intent intent = new Intent("com.android.camera.action.CROP");
            // this will open all images in the Galery
            intent.setDataAndType(uriTarget, "image/jpeg");
            intent.putExtra("crop", "true");
            // this defines the aspect ration
            intent.putExtra("aspectX", 20);
            intent.putExtra("aspectY", 0);
            // this defines the output bitmap size
            //intent.putExtra("outputX", 256);
            //intent.putExtra("outputY", 256);

            // true to return a Bitmap, false to directly save the cropped iamge
            intent.putExtra("return-data", false);
            //save output image in uri
            intent.putExtra(MediaStore.EXTRA_OUTPUT, uriTarget);
            startActivity(intent);


            Intent intent2 = new Intent(Intent.ACTION_SEND);
            intent2.setType("image/jpeg");
            intent2.putExtra(Intent.EXTRA_EMAIL, recipients);
            intent2.putExtra(Intent.EXTRA_SUBJECT, job);
            intent.putExtra(Intent.EXTRA_STREAM, uriTarget.getPath()); // Attaches image to Gmail


              //File shareImg =  new File(uriTarget);
              //intent.putExtra(Intent.EXTRA_STREAM, uriTarget.fromFile(shareImg));

            try {
                startActivity(intent2);

            } catch (android.content.ActivityNotFoundException ex) {

                Toast.makeText(DigitalSignature.this, "There are no email clients installed.", Toast.LENGTH_SHORT).show();
            }

请问有人能帮助我朝着正确的方向前进吗?

谢谢,约翰。

4

1 回答 1

0

您必须startActivityForResult根据 CROP 意图并在收到结果后通过电子邮件发送它。

于 2012-11-08T17:35:41.780 回答