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[]{"[email protected]", "",};
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();
}
會有人能夠幫助引導我朝着正確的方向嗎?
謝謝,約翰。
謝謝你的指示。我正在努力。 –
感謝Budius,立即啓動並運行:) –