2012-11-15 3 views
0

Je crée une application que quand j'ai appuyé sur un bouton envoyez-moi le contenu de TextView à mon email, mais je sais comment faire ceci, j'ai besoin de l'aide.envoyer le contenu de textview et imageview à l'email

Je dois envoyer à l'email tvFechaSi et ImageView à [email protected] (est un faux courriel)

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

Veuillez consulter [ici] [1] pour un exemple. [1]: http://stackoverflow.com/questions/4928700/attaching-an-image-to-an-email –

+0

James Baca dans cette ligne, startActivity (Intent.createChooser (i, "Partager vous sur le travail ")); "Partager vous sur le travail" Je ne comprends pas ce que c'est, si vous pouvez m'expliquer :) –

Répondre

1

Je pense que ce code pourrait vous aider:

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

Vous pouvez utiliser la ACTION_SEND intention d'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

fonctionne très bien, mais comment envoyer une vue d'image? est le plus fondamental dans l'application –

Questions connexes