📜 ⬆️ ⬇️

Sending E-Mail via Android

Hi habr and hello everyone!

In this article, I will show how the sending of letters by means of Android itself is implemented, as well as another more interesting way, but using an external library, which allows us to send letters in ways more acceptable to the programmer.

Part 1. Mail, just Mail


How it is done: usually an additional Activity is built into the program, which is a window with several fields: To, Subject and Text. Further, the data from these fields are transmitted as extra content:
Special Intent: android.content.Intent.ACTION_SEND.
The code itself file SimpleEMail.java
public class SimpleEMail extends Activity { Button send; EditText address, subject, emailtext; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.simple_email); // send = (Button) findViewById(R.id.emailsendbutton); address = (EditText) findViewById(R.id.emailaddress); subject = (EditText) findViewById(R.id.emailsubject); emailtext = (EditText) findViewById(R.id.emailtext); send.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.setType( "plain/text" ); // emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String [] { address.getText().toString() }); // emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject.getText().toString()); // emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, emailtext.getText().toString()); // emailIntent.putExtra( android.content.Intent.EXTRA_STREAM, Uri .parse( "file://" + Environment.getExternalStorageDirectory() + "//SOTY_ATHD.mp4" )); emailIntent.setType( "text/video" ); // ! SimpleEMail. this .startActivity(Intent.createChooser(emailIntent, " ..." )); } }); } } * This source code was highlighted with Source Code Highlighter .
  1. public class SimpleEMail extends Activity { Button send; EditText address, subject, emailtext; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.simple_email); // send = (Button) findViewById(R.id.emailsendbutton); address = (EditText) findViewById(R.id.emailaddress); subject = (EditText) findViewById(R.id.emailsubject); emailtext = (EditText) findViewById(R.id.emailtext); send.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.setType( "plain/text" ); // emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String [] { address.getText().toString() }); // emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject.getText().toString()); // emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, emailtext.getText().toString()); // emailIntent.putExtra( android.content.Intent.EXTRA_STREAM, Uri .parse( "file://" + Environment.getExternalStorageDirectory() + "//SOTY_ATHD.mp4" )); emailIntent.setType( "text/video" ); // ! SimpleEMail. this .startActivity(Intent.createChooser(emailIntent, " ..." )); } }); } } * This source code was highlighted with Source Code Highlighter .
  2. public class SimpleEMail extends Activity { Button send; EditText address, subject, emailtext; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.simple_email); // send = (Button) findViewById(R.id.emailsendbutton); address = (EditText) findViewById(R.id.emailaddress); subject = (EditText) findViewById(R.id.emailsubject); emailtext = (EditText) findViewById(R.id.emailtext); send.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.setType( "plain/text" ); // emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String [] { address.getText().toString() }); // emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject.getText().toString()); // emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, emailtext.getText().toString()); // emailIntent.putExtra( android.content.Intent.EXTRA_STREAM, Uri .parse( "file://" + Environment.getExternalStorageDirectory() + "//SOTY_ATHD.mp4" )); emailIntent.setType( "text/video" ); // ! SimpleEMail. this .startActivity(Intent.createChooser(emailIntent, " ..." )); } }); } } * This source code was highlighted with Source Code Highlighter .
  3. public class SimpleEMail extends Activity { Button send; EditText address, subject, emailtext; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.simple_email); // send = (Button) findViewById(R.id.emailsendbutton); address = (EditText) findViewById(R.id.emailaddress); subject = (EditText) findViewById(R.id.emailsubject); emailtext = (EditText) findViewById(R.id.emailtext); send.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.setType( "plain/text" ); // emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String [] { address.getText().toString() }); // emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject.getText().toString()); // emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, emailtext.getText().toString()); // emailIntent.putExtra( android.content.Intent.EXTRA_STREAM, Uri .parse( "file://" + Environment.getExternalStorageDirectory() + "//SOTY_ATHD.mp4" )); emailIntent.setType( "text/video" ); // ! SimpleEMail. this .startActivity(Intent.createChooser(emailIntent, " ..." )); } }); } } * This source code was highlighted with Source Code Highlighter .
  4. public class SimpleEMail extends Activity { Button send; EditText address, subject, emailtext; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.simple_email); // send = (Button) findViewById(R.id.emailsendbutton); address = (EditText) findViewById(R.id.emailaddress); subject = (EditText) findViewById(R.id.emailsubject); emailtext = (EditText) findViewById(R.id.emailtext); send.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.setType( "plain/text" ); // emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String [] { address.getText().toString() }); // emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject.getText().toString()); // emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, emailtext.getText().toString()); // emailIntent.putExtra( android.content.Intent.EXTRA_STREAM, Uri .parse( "file://" + Environment.getExternalStorageDirectory() + "//SOTY_ATHD.mp4" )); emailIntent.setType( "text/video" ); // ! SimpleEMail. this .startActivity(Intent.createChooser(emailIntent, " ..." )); } }); } } * This source code was highlighted with Source Code Highlighter .
  5. public class SimpleEMail extends Activity { Button send; EditText address, subject, emailtext; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.simple_email); // send = (Button) findViewById(R.id.emailsendbutton); address = (EditText) findViewById(R.id.emailaddress); subject = (EditText) findViewById(R.id.emailsubject); emailtext = (EditText) findViewById(R.id.emailtext); send.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.setType( "plain/text" ); // emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String [] { address.getText().toString() }); // emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject.getText().toString()); // emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, emailtext.getText().toString()); // emailIntent.putExtra( android.content.Intent.EXTRA_STREAM, Uri .parse( "file://" + Environment.getExternalStorageDirectory() + "//SOTY_ATHD.mp4" )); emailIntent.setType( "text/video" ); // ! SimpleEMail. this .startActivity(Intent.createChooser(emailIntent, " ..." )); } }); } } * This source code was highlighted with Source Code Highlighter .
  6. public class SimpleEMail extends Activity { Button send; EditText address, subject, emailtext; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.simple_email); // send = (Button) findViewById(R.id.emailsendbutton); address = (EditText) findViewById(R.id.emailaddress); subject = (EditText) findViewById(R.id.emailsubject); emailtext = (EditText) findViewById(R.id.emailtext); send.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.setType( "plain/text" ); // emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String [] { address.getText().toString() }); // emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject.getText().toString()); // emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, emailtext.getText().toString()); // emailIntent.putExtra( android.content.Intent.EXTRA_STREAM, Uri .parse( "file://" + Environment.getExternalStorageDirectory() + "//SOTY_ATHD.mp4" )); emailIntent.setType( "text/video" ); // ! SimpleEMail. this .startActivity(Intent.createChooser(emailIntent, " ..." )); } }); } } * This source code was highlighted with Source Code Highlighter .
  7. public class SimpleEMail extends Activity { Button send; EditText address, subject, emailtext; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.simple_email); // send = (Button) findViewById(R.id.emailsendbutton); address = (EditText) findViewById(R.id.emailaddress); subject = (EditText) findViewById(R.id.emailsubject); emailtext = (EditText) findViewById(R.id.emailtext); send.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.setType( "plain/text" ); // emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String [] { address.getText().toString() }); // emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject.getText().toString()); // emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, emailtext.getText().toString()); // emailIntent.putExtra( android.content.Intent.EXTRA_STREAM, Uri .parse( "file://" + Environment.getExternalStorageDirectory() + "//SOTY_ATHD.mp4" )); emailIntent.setType( "text/video" ); // ! SimpleEMail. this .startActivity(Intent.createChooser(emailIntent, " ..." )); } }); } } * This source code was highlighted with Source Code Highlighter .
  8. public class SimpleEMail extends Activity { Button send; EditText address, subject, emailtext; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.simple_email); // send = (Button) findViewById(R.id.emailsendbutton); address = (EditText) findViewById(R.id.emailaddress); subject = (EditText) findViewById(R.id.emailsubject); emailtext = (EditText) findViewById(R.id.emailtext); send.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.setType( "plain/text" ); // emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String [] { address.getText().toString() }); // emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject.getText().toString()); // emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, emailtext.getText().toString()); // emailIntent.putExtra( android.content.Intent.EXTRA_STREAM, Uri .parse( "file://" + Environment.getExternalStorageDirectory() + "//SOTY_ATHD.mp4" )); emailIntent.setType( "text/video" ); // ! SimpleEMail. this .startActivity(Intent.createChooser(emailIntent, " ..." )); } }); } } * This source code was highlighted with Source Code Highlighter .
  9. public class SimpleEMail extends Activity { Button send; EditText address, subject, emailtext; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.simple_email); // send = (Button) findViewById(R.id.emailsendbutton); address = (EditText) findViewById(R.id.emailaddress); subject = (EditText) findViewById(R.id.emailsubject); emailtext = (EditText) findViewById(R.id.emailtext); send.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.setType( "plain/text" ); // emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String [] { address.getText().toString() }); // emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject.getText().toString()); // emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, emailtext.getText().toString()); // emailIntent.putExtra( android.content.Intent.EXTRA_STREAM, Uri .parse( "file://" + Environment.getExternalStorageDirectory() + "//SOTY_ATHD.mp4" )); emailIntent.setType( "text/video" ); // ! SimpleEMail. this .startActivity(Intent.createChooser(emailIntent, " ..." )); } }); } } * This source code was highlighted with Source Code Highlighter .
  10. public class SimpleEMail extends Activity { Button send; EditText address, subject, emailtext; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.simple_email); // send = (Button) findViewById(R.id.emailsendbutton); address = (EditText) findViewById(R.id.emailaddress); subject = (EditText) findViewById(R.id.emailsubject); emailtext = (EditText) findViewById(R.id.emailtext); send.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.setType( "plain/text" ); // emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String [] { address.getText().toString() }); // emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject.getText().toString()); // emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, emailtext.getText().toString()); // emailIntent.putExtra( android.content.Intent.EXTRA_STREAM, Uri .parse( "file://" + Environment.getExternalStorageDirectory() + "//SOTY_ATHD.mp4" )); emailIntent.setType( "text/video" ); // ! SimpleEMail. this .startActivity(Intent.createChooser(emailIntent, " ..." )); } }); } } * This source code was highlighted with Source Code Highlighter .
  11. public class SimpleEMail extends Activity { Button send; EditText address, subject, emailtext; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.simple_email); // send = (Button) findViewById(R.id.emailsendbutton); address = (EditText) findViewById(R.id.emailaddress); subject = (EditText) findViewById(R.id.emailsubject); emailtext = (EditText) findViewById(R.id.emailtext); send.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.setType( "plain/text" ); // emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String [] { address.getText().toString() }); // emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject.getText().toString()); // emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, emailtext.getText().toString()); // emailIntent.putExtra( android.content.Intent.EXTRA_STREAM, Uri .parse( "file://" + Environment.getExternalStorageDirectory() + "//SOTY_ATHD.mp4" )); emailIntent.setType( "text/video" ); // ! SimpleEMail. this .startActivity(Intent.createChooser(emailIntent, " ..." )); } }); } } * This source code was highlighted with Source Code Highlighter .
  12. public class SimpleEMail extends Activity { Button send; EditText address, subject, emailtext; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.simple_email); // send = (Button) findViewById(R.id.emailsendbutton); address = (EditText) findViewById(R.id.emailaddress); subject = (EditText) findViewById(R.id.emailsubject); emailtext = (EditText) findViewById(R.id.emailtext); send.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.setType( "plain/text" ); // emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String [] { address.getText().toString() }); // emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject.getText().toString()); // emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, emailtext.getText().toString()); // emailIntent.putExtra( android.content.Intent.EXTRA_STREAM, Uri .parse( "file://" + Environment.getExternalStorageDirectory() + "//SOTY_ATHD.mp4" )); emailIntent.setType( "text/video" ); // ! SimpleEMail. this .startActivity(Intent.createChooser(emailIntent, " ..." )); } }); } } * This source code was highlighted with Source Code Highlighter .
  13. public class SimpleEMail extends Activity { Button send; EditText address, subject, emailtext; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.simple_email); // send = (Button) findViewById(R.id.emailsendbutton); address = (EditText) findViewById(R.id.emailaddress); subject = (EditText) findViewById(R.id.emailsubject); emailtext = (EditText) findViewById(R.id.emailtext); send.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.setType( "plain/text" ); // emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String [] { address.getText().toString() }); // emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject.getText().toString()); // emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, emailtext.getText().toString()); // emailIntent.putExtra( android.content.Intent.EXTRA_STREAM, Uri .parse( "file://" + Environment.getExternalStorageDirectory() + "//SOTY_ATHD.mp4" )); emailIntent.setType( "text/video" ); // ! SimpleEMail. this .startActivity(Intent.createChooser(emailIntent, " ..." )); } }); } } * This source code was highlighted with Source Code Highlighter .
  14. public class SimpleEMail extends Activity { Button send; EditText address, subject, emailtext; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.simple_email); // send = (Button) findViewById(R.id.emailsendbutton); address = (EditText) findViewById(R.id.emailaddress); subject = (EditText) findViewById(R.id.emailsubject); emailtext = (EditText) findViewById(R.id.emailtext); send.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.setType( "plain/text" ); // emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String [] { address.getText().toString() }); // emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject.getText().toString()); // emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, emailtext.getText().toString()); // emailIntent.putExtra( android.content.Intent.EXTRA_STREAM, Uri .parse( "file://" + Environment.getExternalStorageDirectory() + "//SOTY_ATHD.mp4" )); emailIntent.setType( "text/video" ); // ! SimpleEMail. this .startActivity(Intent.createChooser(emailIntent, " ..." )); } }); } } * This source code was highlighted with Source Code Highlighter .
  15. public class SimpleEMail extends Activity { Button send; EditText address, subject, emailtext; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.simple_email); // send = (Button) findViewById(R.id.emailsendbutton); address = (EditText) findViewById(R.id.emailaddress); subject = (EditText) findViewById(R.id.emailsubject); emailtext = (EditText) findViewById(R.id.emailtext); send.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.setType( "plain/text" ); // emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String [] { address.getText().toString() }); // emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject.getText().toString()); // emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, emailtext.getText().toString()); // emailIntent.putExtra( android.content.Intent.EXTRA_STREAM, Uri .parse( "file://" + Environment.getExternalStorageDirectory() + "//SOTY_ATHD.mp4" )); emailIntent.setType( "text/video" ); // ! SimpleEMail. this .startActivity(Intent.createChooser(emailIntent, " ..." )); } }); } } * This source code was highlighted with Source Code Highlighter .
  16. public class SimpleEMail extends Activity { Button send; EditText address, subject, emailtext; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.simple_email); // send = (Button) findViewById(R.id.emailsendbutton); address = (EditText) findViewById(R.id.emailaddress); subject = (EditText) findViewById(R.id.emailsubject); emailtext = (EditText) findViewById(R.id.emailtext); send.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.setType( "plain/text" ); // emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String [] { address.getText().toString() }); // emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject.getText().toString()); // emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, emailtext.getText().toString()); // emailIntent.putExtra( android.content.Intent.EXTRA_STREAM, Uri .parse( "file://" + Environment.getExternalStorageDirectory() + "//SOTY_ATHD.mp4" )); emailIntent.setType( "text/video" ); // ! SimpleEMail. this .startActivity(Intent.createChooser(emailIntent, " ..." )); } }); } } * This source code was highlighted with Source Code Highlighter .
  17. public class SimpleEMail extends Activity { Button send; EditText address, subject, emailtext; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.simple_email); // send = (Button) findViewById(R.id.emailsendbutton); address = (EditText) findViewById(R.id.emailaddress); subject = (EditText) findViewById(R.id.emailsubject); emailtext = (EditText) findViewById(R.id.emailtext); send.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.setType( "plain/text" ); // emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String [] { address.getText().toString() }); // emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject.getText().toString()); // emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, emailtext.getText().toString()); // emailIntent.putExtra( android.content.Intent.EXTRA_STREAM, Uri .parse( "file://" + Environment.getExternalStorageDirectory() + "//SOTY_ATHD.mp4" )); emailIntent.setType( "text/video" ); // ! SimpleEMail. this .startActivity(Intent.createChooser(emailIntent, " ..." )); } }); } } * This source code was highlighted with Source Code Highlighter .
  18. public class SimpleEMail extends Activity { Button send; EditText address, subject, emailtext; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.simple_email); // send = (Button) findViewById(R.id.emailsendbutton); address = (EditText) findViewById(R.id.emailaddress); subject = (EditText) findViewById(R.id.emailsubject); emailtext = (EditText) findViewById(R.id.emailtext); send.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.setType( "plain/text" ); // emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String [] { address.getText().toString() }); // emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject.getText().toString()); // emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, emailtext.getText().toString()); // emailIntent.putExtra( android.content.Intent.EXTRA_STREAM, Uri .parse( "file://" + Environment.getExternalStorageDirectory() + "//SOTY_ATHD.mp4" )); emailIntent.setType( "text/video" ); // ! SimpleEMail. this .startActivity(Intent.createChooser(emailIntent, " ..." )); } }); } } * This source code was highlighted with Source Code Highlighter .
  19. public class SimpleEMail extends Activity { Button send; EditText address, subject, emailtext; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.simple_email); // send = (Button) findViewById(R.id.emailsendbutton); address = (EditText) findViewById(R.id.emailaddress); subject = (EditText) findViewById(R.id.emailsubject); emailtext = (EditText) findViewById(R.id.emailtext); send.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.setType( "plain/text" ); // emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String [] { address.getText().toString() }); // emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject.getText().toString()); // emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, emailtext.getText().toString()); // emailIntent.putExtra( android.content.Intent.EXTRA_STREAM, Uri .parse( "file://" + Environment.getExternalStorageDirectory() + "//SOTY_ATHD.mp4" )); emailIntent.setType( "text/video" ); // ! SimpleEMail. this .startActivity(Intent.createChooser(emailIntent, " ..." )); } }); } } * This source code was highlighted with Source Code Highlighter .
  20. public class SimpleEMail extends Activity { Button send; EditText address, subject, emailtext; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.simple_email); // send = (Button) findViewById(R.id.emailsendbutton); address = (EditText) findViewById(R.id.emailaddress); subject = (EditText) findViewById(R.id.emailsubject); emailtext = (EditText) findViewById(R.id.emailtext); send.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.setType( "plain/text" ); // emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String [] { address.getText().toString() }); // emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject.getText().toString()); // emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, emailtext.getText().toString()); // emailIntent.putExtra( android.content.Intent.EXTRA_STREAM, Uri .parse( "file://" + Environment.getExternalStorageDirectory() + "//SOTY_ATHD.mp4" )); emailIntent.setType( "text/video" ); // ! SimpleEMail. this .startActivity(Intent.createChooser(emailIntent, " ..." )); } }); } } * This source code was highlighted with Source Code Highlighter .
  21. public class SimpleEMail extends Activity { Button send; EditText address, subject, emailtext; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.simple_email); // send = (Button) findViewById(R.id.emailsendbutton); address = (EditText) findViewById(R.id.emailaddress); subject = (EditText) findViewById(R.id.emailsubject); emailtext = (EditText) findViewById(R.id.emailtext); send.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.setType( "plain/text" ); // emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String [] { address.getText().toString() }); // emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject.getText().toString()); // emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, emailtext.getText().toString()); // emailIntent.putExtra( android.content.Intent.EXTRA_STREAM, Uri .parse( "file://" + Environment.getExternalStorageDirectory() + "//SOTY_ATHD.mp4" )); emailIntent.setType( "text/video" ); // ! SimpleEMail. this .startActivity(Intent.createChooser(emailIntent, " ..." )); } }); } } * This source code was highlighted with Source Code Highlighter .
  22. public class SimpleEMail extends Activity { Button send; EditText address, subject, emailtext; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.simple_email); // send = (Button) findViewById(R.id.emailsendbutton); address = (EditText) findViewById(R.id.emailaddress); subject = (EditText) findViewById(R.id.emailsubject); emailtext = (EditText) findViewById(R.id.emailtext); send.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.setType( "plain/text" ); // emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String [] { address.getText().toString() }); // emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject.getText().toString()); // emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, emailtext.getText().toString()); // emailIntent.putExtra( android.content.Intent.EXTRA_STREAM, Uri .parse( "file://" + Environment.getExternalStorageDirectory() + "//SOTY_ATHD.mp4" )); emailIntent.setType( "text/video" ); // ! SimpleEMail. this .startActivity(Intent.createChooser(emailIntent, " ..." )); } }); } } * This source code was highlighted with Source Code Highlighter .
  23. public class SimpleEMail extends Activity { Button send; EditText address, subject, emailtext; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.simple_email); // send = (Button) findViewById(R.id.emailsendbutton); address = (EditText) findViewById(R.id.emailaddress); subject = (EditText) findViewById(R.id.emailsubject); emailtext = (EditText) findViewById(R.id.emailtext); send.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.setType( "plain/text" ); // emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String [] { address.getText().toString() }); // emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject.getText().toString()); // emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, emailtext.getText().toString()); // emailIntent.putExtra( android.content.Intent.EXTRA_STREAM, Uri .parse( "file://" + Environment.getExternalStorageDirectory() + "//SOTY_ATHD.mp4" )); emailIntent.setType( "text/video" ); // ! SimpleEMail. this .startActivity(Intent.createChooser(emailIntent, " ..." )); } }); } } * This source code was highlighted with Source Code Highlighter .
  24. public class SimpleEMail extends Activity { Button send; EditText address, subject, emailtext; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.simple_email); // send = (Button) findViewById(R.id.emailsendbutton); address = (EditText) findViewById(R.id.emailaddress); subject = (EditText) findViewById(R.id.emailsubject); emailtext = (EditText) findViewById(R.id.emailtext); send.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.setType( "plain/text" ); // emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String [] { address.getText().toString() }); // emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject.getText().toString()); // emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, emailtext.getText().toString()); // emailIntent.putExtra( android.content.Intent.EXTRA_STREAM, Uri .parse( "file://" + Environment.getExternalStorageDirectory() + "//SOTY_ATHD.mp4" )); emailIntent.setType( "text/video" ); // ! SimpleEMail. this .startActivity(Intent.createChooser(emailIntent, " ..." )); } }); } } * This source code was highlighted with Source Code Highlighter .
  25. public class SimpleEMail extends Activity { Button send; EditText address, subject, emailtext; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.simple_email); // send = (Button) findViewById(R.id.emailsendbutton); address = (EditText) findViewById(R.id.emailaddress); subject = (EditText) findViewById(R.id.emailsubject); emailtext = (EditText) findViewById(R.id.emailtext); send.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.setType( "plain/text" ); // emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String [] { address.getText().toString() }); // emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject.getText().toString()); // emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, emailtext.getText().toString()); // emailIntent.putExtra( android.content.Intent.EXTRA_STREAM, Uri .parse( "file://" + Environment.getExternalStorageDirectory() + "//SOTY_ATHD.mp4" )); emailIntent.setType( "text/video" ); // ! SimpleEMail. this .startActivity(Intent.createChooser(emailIntent, " ..." )); } }); } } * This source code was highlighted with Source Code Highlighter .
  26. public class SimpleEMail extends Activity { Button send; EditText address, subject, emailtext; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.simple_email); // send = (Button) findViewById(R.id.emailsendbutton); address = (EditText) findViewById(R.id.emailaddress); subject = (EditText) findViewById(R.id.emailsubject); emailtext = (EditText) findViewById(R.id.emailtext); send.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.setType( "plain/text" ); // emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String [] { address.getText().toString() }); // emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject.getText().toString()); // emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, emailtext.getText().toString()); // emailIntent.putExtra( android.content.Intent.EXTRA_STREAM, Uri .parse( "file://" + Environment.getExternalStorageDirectory() + "//SOTY_ATHD.mp4" )); emailIntent.setType( "text/video" ); // ! SimpleEMail. this .startActivity(Intent.createChooser(emailIntent, " ..." )); } }); } } * This source code was highlighted with Source Code Highlighter .
  27. public class SimpleEMail extends Activity { Button send; EditText address, subject, emailtext; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.simple_email); // send = (Button) findViewById(R.id.emailsendbutton); address = (EditText) findViewById(R.id.emailaddress); subject = (EditText) findViewById(R.id.emailsubject); emailtext = (EditText) findViewById(R.id.emailtext); send.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.setType( "plain/text" ); // emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String [] { address.getText().toString() }); // emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject.getText().toString()); // emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, emailtext.getText().toString()); // emailIntent.putExtra( android.content.Intent.EXTRA_STREAM, Uri .parse( "file://" + Environment.getExternalStorageDirectory() + "//SOTY_ATHD.mp4" )); emailIntent.setType( "text/video" ); // ! SimpleEMail. this .startActivity(Intent.createChooser(emailIntent, " ..." )); } }); } } * This source code was highlighted with Source Code Highlighter .
  28. public class SimpleEMail extends Activity { Button send; EditText address, subject, emailtext; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.simple_email); // send = (Button) findViewById(R.id.emailsendbutton); address = (EditText) findViewById(R.id.emailaddress); subject = (EditText) findViewById(R.id.emailsubject); emailtext = (EditText) findViewById(R.id.emailtext); send.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.setType( "plain/text" ); // emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String [] { address.getText().toString() }); // emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject.getText().toString()); // emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, emailtext.getText().toString()); // emailIntent.putExtra( android.content.Intent.EXTRA_STREAM, Uri .parse( "file://" + Environment.getExternalStorageDirectory() + "//SOTY_ATHD.mp4" )); emailIntent.setType( "text/video" ); // ! SimpleEMail. this .startActivity(Intent.createChooser(emailIntent, " ..." )); } }); } } * This source code was highlighted with Source Code Highlighter .
  29. public class SimpleEMail extends Activity { Button send; EditText address, subject, emailtext; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.simple_email); // send = (Button) findViewById(R.id.emailsendbutton); address = (EditText) findViewById(R.id.emailaddress); subject = (EditText) findViewById(R.id.emailsubject); emailtext = (EditText) findViewById(R.id.emailtext); send.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.setType( "plain/text" ); // emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String [] { address.getText().toString() }); // emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject.getText().toString()); // emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, emailtext.getText().toString()); // emailIntent.putExtra( android.content.Intent.EXTRA_STREAM, Uri .parse( "file://" + Environment.getExternalStorageDirectory() + "//SOTY_ATHD.mp4" )); emailIntent.setType( "text/video" ); // ! SimpleEMail. this .startActivity(Intent.createChooser(emailIntent, " ..." )); } }); } } * This source code was highlighted with Source Code Highlighter .
  30. public class SimpleEMail extends Activity { Button send; EditText address, subject, emailtext; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.simple_email); // send = (Button) findViewById(R.id.emailsendbutton); address = (EditText) findViewById(R.id.emailaddress); subject = (EditText) findViewById(R.id.emailsubject); emailtext = (EditText) findViewById(R.id.emailtext); send.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.setType( "plain/text" ); // emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String [] { address.getText().toString() }); // emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject.getText().toString()); // emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, emailtext.getText().toString()); // emailIntent.putExtra( android.content.Intent.EXTRA_STREAM, Uri .parse( "file://" + Environment.getExternalStorageDirectory() + "//SOTY_ATHD.mp4" )); emailIntent.setType( "text/video" ); // ! SimpleEMail. this .startActivity(Intent.createChooser(emailIntent, " ..." )); } }); } } * This source code was highlighted with Source Code Highlighter .
  31. public class SimpleEMail extends Activity { Button send; EditText address, subject, emailtext; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.simple_email); // send = (Button) findViewById(R.id.emailsendbutton); address = (EditText) findViewById(R.id.emailaddress); subject = (EditText) findViewById(R.id.emailsubject); emailtext = (EditText) findViewById(R.id.emailtext); send.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.setType( "plain/text" ); // emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String [] { address.getText().toString() }); // emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject.getText().toString()); // emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, emailtext.getText().toString()); // emailIntent.putExtra( android.content.Intent.EXTRA_STREAM, Uri .parse( "file://" + Environment.getExternalStorageDirectory() + "//SOTY_ATHD.mp4" )); emailIntent.setType( "text/video" ); // ! SimpleEMail. this .startActivity(Intent.createChooser(emailIntent, " ..." )); } }); } } * This source code was highlighted with Source Code Highlighter .
  32. public class SimpleEMail extends Activity { Button send; EditText address, subject, emailtext; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.simple_email); // send = (Button) findViewById(R.id.emailsendbutton); address = (EditText) findViewById(R.id.emailaddress); subject = (EditText) findViewById(R.id.emailsubject); emailtext = (EditText) findViewById(R.id.emailtext); send.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.setType( "plain/text" ); // emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String [] { address.getText().toString() }); // emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject.getText().toString()); // emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, emailtext.getText().toString()); // emailIntent.putExtra( android.content.Intent.EXTRA_STREAM, Uri .parse( "file://" + Environment.getExternalStorageDirectory() + "//SOTY_ATHD.mp4" )); emailIntent.setType( "text/video" ); // ! SimpleEMail. this .startActivity(Intent.createChooser(emailIntent, " ..." )); } }); } } * This source code was highlighted with Source Code Highlighter .
  33. public class SimpleEMail extends Activity { Button send; EditText address, subject, emailtext; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.simple_email); // send = (Button) findViewById(R.id.emailsendbutton); address = (EditText) findViewById(R.id.emailaddress); subject = (EditText) findViewById(R.id.emailsubject); emailtext = (EditText) findViewById(R.id.emailtext); send.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.setType( "plain/text" ); // emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String [] { address.getText().toString() }); // emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject.getText().toString()); // emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, emailtext.getText().toString()); // emailIntent.putExtra( android.content.Intent.EXTRA_STREAM, Uri .parse( "file://" + Environment.getExternalStorageDirectory() + "//SOTY_ATHD.mp4" )); emailIntent.setType( "text/video" ); // ! SimpleEMail. this .startActivity(Intent.createChooser(emailIntent, " ..." )); } }); } } * This source code was highlighted with Source Code Highlighter .
  34. public class SimpleEMail extends Activity { Button send; EditText address, subject, emailtext; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.simple_email); // send = (Button) findViewById(R.id.emailsendbutton); address = (EditText) findViewById(R.id.emailaddress); subject = (EditText) findViewById(R.id.emailsubject); emailtext = (EditText) findViewById(R.id.emailtext); send.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.setType( "plain/text" ); // emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String [] { address.getText().toString() }); // emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject.getText().toString()); // emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, emailtext.getText().toString()); // emailIntent.putExtra( android.content.Intent.EXTRA_STREAM, Uri .parse( "file://" + Environment.getExternalStorageDirectory() + "//SOTY_ATHD.mp4" )); emailIntent.setType( "text/video" ); // ! SimpleEMail. this .startActivity(Intent.createChooser(emailIntent, " ..." )); } }); } } * This source code was highlighted with Source Code Highlighter .
  35. public class SimpleEMail extends Activity { Button send; EditText address, subject, emailtext; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.simple_email); // send = (Button) findViewById(R.id.emailsendbutton); address = (EditText) findViewById(R.id.emailaddress); subject = (EditText) findViewById(R.id.emailsubject); emailtext = (EditText) findViewById(R.id.emailtext); send.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.setType( "plain/text" ); // emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String [] { address.getText().toString() }); // emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject.getText().toString()); // emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, emailtext.getText().toString()); // emailIntent.putExtra( android.content.Intent.EXTRA_STREAM, Uri .parse( "file://" + Environment.getExternalStorageDirectory() + "//SOTY_ATHD.mp4" )); emailIntent.setType( "text/video" ); // ! SimpleEMail. this .startActivity(Intent.createChooser(emailIntent, " ..." )); } }); } } * This source code was highlighted with Source Code Highlighter .
  36. public class SimpleEMail extends Activity { Button send; EditText address, subject, emailtext; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.simple_email); // send = (Button) findViewById(R.id.emailsendbutton); address = (EditText) findViewById(R.id.emailaddress); subject = (EditText) findViewById(R.id.emailsubject); emailtext = (EditText) findViewById(R.id.emailtext); send.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.setType( "plain/text" ); // emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String [] { address.getText().toString() }); // emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject.getText().toString()); // emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, emailtext.getText().toString()); // emailIntent.putExtra( android.content.Intent.EXTRA_STREAM, Uri .parse( "file://" + Environment.getExternalStorageDirectory() + "//SOTY_ATHD.mp4" )); emailIntent.setType( "text/video" ); // ! SimpleEMail. this .startActivity(Intent.createChooser(emailIntent, " ..." )); } }); } } * This source code was highlighted with Source Code Highlighter .
  37. public class SimpleEMail extends Activity { Button send; EditText address, subject, emailtext; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.simple_email); // send = (Button) findViewById(R.id.emailsendbutton); address = (EditText) findViewById(R.id.emailaddress); subject = (EditText) findViewById(R.id.emailsubject); emailtext = (EditText) findViewById(R.id.emailtext); send.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.setType( "plain/text" ); // emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String [] { address.getText().toString() }); // emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject.getText().toString()); // emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, emailtext.getText().toString()); // emailIntent.putExtra( android.content.Intent.EXTRA_STREAM, Uri .parse( "file://" + Environment.getExternalStorageDirectory() + "//SOTY_ATHD.mp4" )); emailIntent.setType( "text/video" ); // ! SimpleEMail. this .startActivity(Intent.createChooser(emailIntent, " ..." )); } }); } } * This source code was highlighted with Source Code Highlighter .
  38. public class SimpleEMail extends Activity { Button send; EditText address, subject, emailtext; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.simple_email); // send = (Button) findViewById(R.id.emailsendbutton); address = (EditText) findViewById(R.id.emailaddress); subject = (EditText) findViewById(R.id.emailsubject); emailtext = (EditText) findViewById(R.id.emailtext); send.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.setType( "plain/text" ); // emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String [] { address.getText().toString() }); // emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject.getText().toString()); // emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, emailtext.getText().toString()); // emailIntent.putExtra( android.content.Intent.EXTRA_STREAM, Uri .parse( "file://" + Environment.getExternalStorageDirectory() + "//SOTY_ATHD.mp4" )); emailIntent.setType( "text/video" ); // ! SimpleEMail. this .startActivity(Intent.createChooser(emailIntent, " ..." )); } }); } } * This source code was highlighted with Source Code Highlighter .
  39. public class SimpleEMail extends Activity { Button send; EditText address, subject, emailtext; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.simple_email); // send = (Button) findViewById(R.id.emailsendbutton); address = (EditText) findViewById(R.id.emailaddress); subject = (EditText) findViewById(R.id.emailsubject); emailtext = (EditText) findViewById(R.id.emailtext); send.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.setType( "plain/text" ); // emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String [] { address.getText().toString() }); // emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject.getText().toString()); // emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, emailtext.getText().toString()); // emailIntent.putExtra( android.content.Intent.EXTRA_STREAM, Uri .parse( "file://" + Environment.getExternalStorageDirectory() + "//SOTY_ATHD.mp4" )); emailIntent.setType( "text/video" ); // ! SimpleEMail. this .startActivity(Intent.createChooser(emailIntent, " ..." )); } }); } } * This source code was highlighted with Source Code Highlighter .
  40. public class SimpleEMail extends Activity { Button send; EditText address, subject, emailtext; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.simple_email); // send = (Button) findViewById(R.id.emailsendbutton); address = (EditText) findViewById(R.id.emailaddress); subject = (EditText) findViewById(R.id.emailsubject); emailtext = (EditText) findViewById(R.id.emailtext); send.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.setType( "plain/text" ); // emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String [] { address.getText().toString() }); // emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject.getText().toString()); // emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, emailtext.getText().toString()); // emailIntent.putExtra( android.content.Intent.EXTRA_STREAM, Uri .parse( "file://" + Environment.getExternalStorageDirectory() + "//SOTY_ATHD.mp4" )); emailIntent.setType( "text/video" ); // ! SimpleEMail. this .startActivity(Intent.createChooser(emailIntent, " ..." )); } }); } } * This source code was highlighted with Source Code Highlighter .
public class SimpleEMail extends Activity { Button send; EditText address, subject, emailtext; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.simple_email); // send = (Button) findViewById(R.id.emailsendbutton); address = (EditText) findViewById(R.id.emailaddress); subject = (EditText) findViewById(R.id.emailsubject); emailtext = (EditText) findViewById(R.id.emailtext); send.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.setType( "plain/text" ); // emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String [] { address.getText().toString() }); // emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject.getText().toString()); // emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, emailtext.getText().toString()); // emailIntent.putExtra( android.content.Intent.EXTRA_STREAM, Uri .parse( "file://" + Environment.getExternalStorageDirectory() + "//SOTY_ATHD.mp4" )); emailIntent.setType( "text/video" ); // ! SimpleEMail. this .startActivity(Intent.createChooser(emailIntent, " ..." )); } }); } } * This source code was highlighted with Source Code Highlighter .
Here, the code is ugly simple. The truth can be even simpler: if we are too lazy to create an additional Activity to enter our fields, then we could just run our Intent.

Pros: Simple implementation, convenient enough for feedback.
Minuses: The user must have a configured program for sending and receiving e-mail messages, without it there will be no one to handle this Intent.
')

Part 2. Mail, anonymus Mail


I used this method in my project, we will first designate the advantages:
Additional libraries javamail-android are necessary for work.
Download them and build them into the project: Context menu of the project> “Build Path”> “Add External Archives ...”> “Our files are additional, mail, activation”

To configure, we also need a mailbox registered on gmail.com (or any other yandex, mail, etc.) settings you can see here . In this case, he will act as a gateway through which our letters will pass.

We start to customize:
MailSenderClass.java
This class contains settings for the server through which your message will be sent. Here we have several methods:

Consider the code for the last method a little closer
  1. public synchronized void sendMail ( String subject, String body, String sender, String recipients, String filename) throws Exception {
  2. try {
  3. MimeMessage message = new MimeMessage (session);
  4. // Who
  5. message.setSender ( new InternetAddress (sender));
  6. // About what
  7. message.setSubject (subject);
  8. // To
  9. if (recipients.indexOf ( ',' )> 0)
  10. message.setRecipients (Message.RecipientType.TO,
  11. InternetAddress.parse (recipients));
  12. else
  13. message.setRecipient (Message.RecipientType.TO,
  14. new InternetAddress (recipients));
  15. // wants to say
  16. BodyPart messageBodyPart = new MimeBodyPart ();
  17. messageBodyPart.setText (body);
  18. _multipart.addBodyPart (messageBodyPart);
  19. // And what to show
  20. if (! filename.equalsIgnoreCase ( "" )) {
  21. BodyPart attachBodyPart = new MimeBodyPart ();
  22. DataSource source = new FileDataSource (filename);
  23. attachBodyPart.setDataHandler ( new DataHandler (source));
  24. attachBodyPart.setFileName (filename);
  25. _multipart.addBodyPart (attachBodyPart);
  26. }
  27. message.setContent (_multipart);
  28. Transport.send (message);
  29. } catch (Exception e) {
  30. Log.e ( "sendMail" , "Error sending function sendMail!" );
  31. }
  32. }
* This source code was highlighted with Source Code Highlighter .
The method is also simple. Using the object of the MimeMessage class we compose our letter and for sending it is passed to the send method of the Transport class.

JSSEProvider.java
Security protocol provider for our mail. Link

VideoSelect.java
The code was taken from ApiDemos, which comes bundled with the Android SDK, and was slightly tampered with using the startActivityForResult method.
After execution, it returns a string containing the path to the file on the memory card. The code can be viewed in the project, it is at the end of the article.

ExtendedMail.java
The main method of sending a message is performed in the sitv_sender_mail_async function, which represents the AsyncTask class:
  1. private class sender_mail_async extends AsyncTask <Object, String , Boolean> {
  2. ProgressDialog WaitingDialog;
  3. @Override
  4. protected void onPreExecute () {
  5. // Display the loading process for the user
  6. WaitingDialog = ProgressDialog.show (ExtendedMail. This , "Sending data" , "We are sending a message ..." , true );
  7. }
  8. @Override
  9. protected void onPostExecute (Boolean result) {
  10. // Hide the boot process
  11. WaitingDialog.dismiss ();
  12. Toast.makeText (mainContext, "Sending complete !!!" , Toast.LENGTH_LONG) .show ();
  13. ((Activity) mainContext) .finish ();
  14. }
  15. @Override
  16. protected Boolean doInBackground (Object ... params ) {
  17. try {
  18. // Get data from our fields
  19. title = ((EditText) findViewById (R.id.screen_sendnews_et_title)). getText (). toString ();
  20. text = ((EditText) findViewById (R.id.screen_sendnews_et_text)). getText (). toString ();
  21. from = "from_post_msg@gmail.com" ;
  22. where = "where_post_msg@yandex.ru" ;
  23. // Call the constructor and transfer our login and password from the mailbox to gmail.com
  24. MailSenderClass sender = new MailSenderClass ( "mypostmail@gmail.com" , "password" );
  25. // And call our send method
  26. sender.sendMail (title, text, from , where , attach);
  27. } catch (Exception e) {
  28. Toast.makeText (mainContext, "Error sending message!" , Toast.LENGTH_SHORT) .show ();
  29. }
  30. return false ;
  31. }
  32. }
* This source code was highlighted with Source Code Highlighter .
Quite simply, we created an instance of the MailSenderClass class, passed the login and password to the designer. Then call sendMail send method with our parameters.
An asynchronous process consists of three onPreExecute (), doInBackground () and onPostExecute () methods, which are executed in written sequence.
For those who forgot how to use it here is the code:
  1. public void onClick (View v) {
  2. sender_mail_async async_sending = new sender_mail_async ();
  3. async_sending.execute ();
  4. }
* This source code was highlighted with Source Code Highlighter .

Thus, by creating a small class stream, you can safely send the necessary information from the client to your inbox.

The source code of the application can be downloaded here .

Source: https://habr.com/ru/post/112450/


All Articles