2012-11-15 35 views
0

我正在創建一個應用程序,當我按下按鈕時,將TextView內容發送給我的電子郵件,但我知道如何做到這一點,我需要幫助。發送textview內容和imageview到電子郵件

我需要發送電子郵件tvFechaSi和ImageView的到[email protected](是假的電子郵件)

public class FormBotonSi extends Activity { 

     private String SFecha; 
     private TextView tvFechaSi ;  
     private static final int CAMERA_REQUEST = 1888; 
     private ImageView imageView; 


    @Override 
    public void onCreate(Bundle savedInstanceState) 
    { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.formbotonsi); 

     Bundle bundle=getIntent().getExtras(); 


     tvFechaSi=(TextView) findViewById(R.id.tvFechaSi); 
     Fecha =bundle.getString("Fecha"); 
     tvFechaSi.setText(Fecha.toString()); 

     this.imageView = (ImageView)this.findViewById(R.id.imageView1); 
     Button photoButton = (Button) this.findViewById(R.id.button1); 


     Spinner sp = (Spinner) findViewById(R.id.spinner1); 
     ArrayAdapter adapter = ArrayAdapter.createFromResource(
      this, R.array.tipoPrioridad, android.R.layout.simple_spinner_item); 
     adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); 
     sp.setAdapter(adapter); 




     photoButton.setOnClickListener(new View.OnClickListener() { 

      public void onClick(View v) { 
       Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); 
       startActivityForResult(cameraIntent, CAMERA_REQUEST); 
      } 
     }); 
    } 

    protected void onActivityResult(int requestCode, int resultCode, Intent data) { 
     if (requestCode == CAMERA_REQUEST && resultCode == RESULT_OK) { 
      Bitmap photo = (Bitmap) data.getExtras().get("data"); 
      imageView.setImageBitmap(photo); 
     } 
    } 

} 
+1

請看[這裏] [1]爲例。 [1]:http://stackoverflow.com/questions/4928700/attaching-an-image-to-an-email –

+0

詹姆斯巴卡在此行中,startActivity(Intent.createChooser(I,「共享你在工作上「)); 「分享你的工作」我不明白這是什麼,如果你能解釋我:) –

回答

1

我覺得這個代碼可以幫助你:

Intent sendIntent = new Intent(Intent.ACTION_SEND); 
sendIntent.putExtra(Intent.EXTRA_EMAIL, new String[]{"[email protected]"}); 
sendIntent.putExtra(Intent.EXTRA_SUBJECT, "Email Subject"); 
sendIntent.putExtra(Intent.EXTRA_STREAM,tvFechaSi.getText()); 
sendIntent.setType("text/html"); 
startActivity(sendIntent); 
0

可以使用ACTION_SEND intent action:

Intent i = new Intent(Intent.ACTION_SEND); 
i.putExtra(Intent.EXTRA_EMAIL, new String[]{"[email protected]"}); 
i.putExtra(Intent.EXTRA_SUBJECT,"subject goes here"); 
i.putExtra(Intent.EXTRA_TEXT, tvFechaSi.getText()); 
startActivity(Intent.createChooser(i, "Select email application.")); 
+0

工作正常,但如何發送圖像視圖?是應用程序中最基本的 –