簡體   English   中英

Android-打開帶有附件提示的電子郵件意圖

[英]Android - Open email intent with attachment prompt

一直試圖弄清楚這一點,似乎找不到任何有關如何實現它的線索。

我正在嘗試啟動旨在發送電子郵件的電子郵件,但是它還會自動打開附件提示,以便用戶可以選擇要附加到電子郵件的圖像。

有人知道這樣做的方法嗎?

目前,我正在使用發送電子郵件的標准方式,如下所示:

        Intent emailIntent = new Intent(Intent.ACTION_SEND);
        emailIntent.setType("message/rfc822");
        emailIntent.putExtra(Intent.EXTRA_EMAIL  , new String[]{"test@email.com"});
        emailIntent.putExtra(Intent.EXTRA_SUBJECT, "test");

        try {
            startActivity(emailIntent);
        } catch (android.content.ActivityNotFoundException ex) {
            Toast.makeText(MainActivity.this, "No e-mail client found!", Toast.LENGTH_SHORT).show();
        }
    }

感謝任何幫助。

編輯:

如果無法做到這一點,那么是否有一種方法可以流式傳輸相機拍攝的圖像(多個)並將其添加為意圖的附件? 似乎無法找到一種方法來處理多幅圖像,只有一張圖像,這就是我在要求一次獲取多張圖像並將其通過電子郵件發送之前設置應用程序的方式。

編輯2:

從相機意圖進入onActivityResult后,使用此方法拍攝多張照片。

    if (resultCode == Activity.RESULT_OK) {

            uriList.add(Uri.fromFile(photoFile));

            try {

                Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
                photoFile = CreateImageFile();
                takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photoFile));
                resultCode = 9999;
                startActivityForResult(takePictureIntent, CAMERA_REQUEST);

            } catch (Exception e) {
            }           
    }
String Message="<b>Name :</b> "+ed_name.getText().toString()+"<br><br>"+
               "<b>Email : </b>"+ed_email.getText().toString()+"<br><br>"+
               "<b>Mobile Number : </b>"+ed_mobile.getText().toString()+"<br><br>"+
               "<b>City : </b>"+ed_city.getText().toString()+"<br><br>"+
               "<b>Subject : </b>"+ed_subject.getText().toString()+"<br><br>"+
               "<b>Inquiry : </b>"+ed_msg.getText().toString()+"<br><br>";

            Spanned FinalMessage=Html.fromHtml(Message);


            Intent emailIntent = new Intent(Intent.ACTION_SEND);
            emailIntent.setType("message/rfc822");
            emailIntent.putExtra(Intent.EXTRA_EMAIL,new String[]{"test@gmail.com"});
            emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Inquiry By : "+ed_name.getText().toString());
            emailIntent.putExtra(Intent.EXTRA_TEXT,FinalMessage);
            //emailIntent.putExtra(Intent.EXTRA_BCC, new String[] {GlobleVaribles.EmailBCC });
            //emailIntent.putExtra(Intent.EXTRA_CC, new String[] {GlobleVaribles.EmailCC });
            startActivity(Intent.createChooser(emailIntent, "Pick an Email provider"));

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM