簡體   English   中英

將圖片插入版式,然后用於發送電子郵件給App

[英]Insert Image into Layout then use in intent to Email App

好的,所以我想看看是否可以完成。 所以我為我的申請提交了一份基本表格。 用戶可以在其中填寫一些信息,例如支持請求。 這由幾個編輯文本和查看文本組成。 然后,它具有一些文本構建器代碼,可將文本合並在一起,並意圖將其合並到android系統,以通過電子郵件進行輸出。

因此,我想知道的是如何將圖像添加到該因素中。

     public void onClick(View v) {
        String[] recipients = new String[]{"email@email.com", "email@email.com",};
          String subject = textSubject.getText().toString();
          String message = "Name:\n" + nametext.getText().toString();
          message += "\n\nEmail:\n" + emailtext.getText().toString();
          message += "\n\nContact#:\n" + phonetext.getText().toString();
          message += "\n\nTopic:\n" + topictext.getText().toString();
          message += "\n\nDescription:\n" + detailstext.getText().toString();
          message += "\n\n" + sentby.toString();


          Intent email = new Intent(Intent.ACTION_SEND);
          email.putExtra(android.content.Intent.EXTRA_EMAIL, recipients);
          //email.putExtra(Intent.EXTRA_CC, new String[]{ to});
          //email.putExtra(Intent.EXTRA_BCC, new String[]{to});
          email.putExtra(Intent.EXTRA_SUBJECT, subject);
          email.putExtra(Intent.EXTRA_TEXT, message);

          //need this to prompts email client only
          email.setType("message/rfc822");
          //plain text
          email.setType("text/plain");

          startActivity(Intent.createChooser(email, "Choose an Email client  :"));
          finish();

        }
    });

因此,這是字符串生成器代碼將XML布局文件上的編輯文本表單內鍵入的內容進行合並的示例代碼。

現在我想弄清楚該怎么做,是我需要在xml布局上添加一個插入圖像按鈕的代碼,從用戶的文件管理器或圖庫應用中選擇圖像的代碼,然后如何將其添加到通過電子郵件發送的總體意圖。

任何建議,反饋,源代碼示例和任何幫助。 提前致謝。

更新

我找到了下面的代碼,並想知道是否有人使用過它,以及它是否可以在我上面的代碼中工作。

 sendIntent.putExtra(Intent.EXTRA_STREAM, "file:///sdcard/mysong.mp3");

您需要使用android.net.Uri

sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///sdcard/mysong.mp3"));

將文件附加到電子郵件是可行的。

暫無
暫無

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

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