2011-08-09 9 views
0

メール本文に画像を表示できません。そのちょうど点在した小さな箱のように見える。メール本文をメール本文に送信する方法

setContentView(R.layout.mailshare); 
    send = (Button)findViewById(R.id.button1); 
    address = (EditText)findViewById(R.id.emailaddress); 
    //subject = (EditText)findViewById(R.id.emailsubject); 
    // emailtext = (EditText)findViewById(R.id.emailtext); 
    Bundle extras = getIntent().getExtras(); 
    if(extras != null) { 
     String emailtitle = extras.getString(TEXT_DATA); 
     if(emailtitle != null) { 
      subject = (EditText)findViewById(R.id.emailsubject); 
      if(subject != null) { 
       subject.setText(emailtitle); 
      } 
     } 
    } 

    Bundle mailmsg = getIntent().getExtras(); 
    if(mailmsg != null) { 
     String bodytext = mailmsg.getString(BODY_TEXT); 
     if(bodytext != null) { 
       emailtext = (EditText)findViewById(R.id.emailtext); 
      if(subject != null) { 
       emailtext.setText(bodytext); 
      } 
     } 
    } 

    send.setOnClickListener(new OnClickListener() { 

     public void onClick(View v) { 
      [enter link description here][2]//     
      // TODO Auto-generated method stub 
      final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); 
      emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{ address.getText().toString()}); 
      emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject.getText()); 
      emailIntent.setType("image/png"); 

      Spanned html =Html.fromHtml("<html><body> <img src='http://www.example.com/logo.png'> </body></html>", 

        new ImageGetter() { 

        InputStream s; 
        public Drawable getDrawable(String url) { 

         try { 
         s = (InputStream) (new URL(url)).getContent(); 
         } catch (MalformedURLException e) { 

         e.printStackTrace(); 
         } catch (IOException e) { 

        e.printStackTrace(); 
        } 
        Drawable d = Drawable.createFromStream(s, null); 
        // Log.debug(this, "Got image: " + d.getClass() + ", " + d.getIntrinsicWidth() + "x" + d.getIntrinsicHeight()); 
        d.setBounds(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight()); 
        return d; 
        }},null); 
       // emailIntent.putExtra(emailIntent.EXTRA_TEXT, html); 
        emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, html); 
        startActivity(Intent.createChooser(emailIntent, "Send mail...")); 



     } 
    }); 

} 

}

答えて

1

Iはテキストに顔文字を追加するためSpannableStringBuilderとImageSpanを用います。

+0

こんにちはVikky ...次のコードでやった、しかし、私は、メール本文のテキストの末尾にロゴを追加する必要があります。どのような方法でもあります – user537771

+0

私はvikkyに感謝していますが、上記のコードを使用していますが、表示できませんでした。 – user537771

2

こんにちは私は

SpannableStringBuilder builder = new SpannableStringBuilder(text); 
Matcher matcher = mPattern.matcher(text); 
while (matcher.find()) { 
      int resId = mSmileyToRes.get(matcher.group()); 
      builder.setSpan(new ImageSpan(mContext, resId), matcher.start(), matcher.end(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); 
} 



(Editable) editMessageText.setText (builder); 
+0

このコードは笑顔のテキストを追加するために使用されていますが、画像(.png、.jpeg)上記のメール本文に画像を追加するコード – user537771

関連する問題