Androidを使用した電子メール送信

こんにちは、Habrと皆さんこんにちは!



この記事では、Android自体を使用してレターを送信する方法と、さらに興味深い方法を示しますが、プログラマーが受け入れやすい方法でレターを送信できる外部ライブラリを使用します。



パート1.メール、メールのみ



これを行う方法:通常、追加のアクティビティがプログラムに組み込まれます。これは、To、Subject、およびTextのいくつかのフィールドを持つウィンドウです。 さらに、これらのフィールドのデータは追加コンテンツとして送信されます。

特別な意図:android.content.Intent.ACTION_SEND。

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 .



さて、コードはいシンプルです。 真実はさらに単純です。フィールドに入るための追加アクティビティを作成するのが面倒なら、インテントを起動するだけで済みます。



長所:簡単な実装で、フィードバックに十分便利です。

短所:ユーザーは、メールメッセージを送受信するためのプログラムを設定する必要があります。これがないと、このインテントを処理する人はいません。



パート2.メール、匿名メール



プロジェクトでこの方法を使用しました。まず利点の概要を説明します。

操作には、追加のjavamail-androidライブラリが必要です。

それらをダウンロードし、プロジェクトに埋め込みます:プロジェクトコンテキストメニュー> "ビルドパス"> "外部アーカイブの追加..."> "追加ファイル、メール、アクティベーション"



構成するには、gmail.comに登録されたメールボックス(またはその他のyandex、メールなど)の設定も必要です( ここで確認できます)。 この場合、それは私たちの手紙が通過するゲートウェイとして機能します。



設定を開始します。

MailSenderClass.java

このクラスでは、メッセージが送信されるサーバーの設定が記録されます。 ここにいくつかの方法があります:



最後のメソッドのコードをもう少し詳しく見てみましょう。





  1. public synchronized void sendMail( 文字列の件名、 文字列の本体、 文字列の送信者、 文字列の受信者、 文字列のファイル名)が例外をスローします{
  2. {
  3. MimeMessageメッセージ= 新しい MimeMessage(セッション);
  4. //誰
  5. message.setSender( 新しい InternetAddress(送信者));
  6. //どうですか
  7. message.setSubject(サブジェクト);
  8. //に
  9. if (recipients.indexOf( '、' )> 0)
  10. message.setRecipients(Message.RecipientType.TO、
  11. InternetAddress.parse(recipients));
  12. 他に
  13. message.setRecipient(Message.RecipientType.TO、
  14. 新しい InternetAddress(受信者));
  15. //言いたい
  16. BodyPart messageBodyPart = new MimeBodyPart();
  17. messageBodyPart.setText(body);
  18. _multipart.addBodyPart(messageBodyPart);
  19. //そして何を表示するか
  20. if (!filename.equalsIgnoreCase( "" )){
  21. BodyPart attachBodyPart = new MimeBodyPart();
  22. DataSource source = new FileDataSource(ファイル名);
  23. attachBodyPart.setDataHandler( 新しい DataHandler(ソース));
  24. attachBodyPart.setFileName(ファイル名);
  25. _multipart.addBodyPart(attachBodyPart);
  26. }
  27. message.setContent(_multipart);
  28. Transport.send(メッセージ);
  29. } catch (例外e){
  30. Log.e( "sendMail""関数sendmail!の送信エラー!" );
  31. }
  32. }
*このソースコードは、 ソースコードハイライターで強調表示されました。
この方法も簡単です。 MimeMessageクラスのオブジェクトを使用して、レター作成し、送信用にTransportメソッドであるsendメソッドに渡します。



JSSEProvider.java

メールのセキュリティプロトコルプロバイダー。 リンク



VideoSelect.java

コードは、Android SDKにバンドルされているApiDemosから取得したもので、startActivityForResultメソッドを使用して実行するために微調整されました。

実行後、メモリカード上のファイルへのパスを含む文字列が返されます。 このコードはプロジェクトで見ることができ、記事の最後にあります。



ExtendedMail.java

メッセージを送信するための主な方法は、AsyncTaskクラスを表すsitv_sender_mail_async関数で実行されます。





  1. private class sender_mail_async extends AsyncTask <Object、 String 、Boolean> {
  2. ProgressDialog WaitingDialog;
  3. @Override
  4. protected void onPreExecute(){
  5. //ユーザーの起動プロセスを表示します
  6. WaitingDialog = ProgressDialog.show(ExtendedMail。This、 "Sending data""Sending a message ..."true );
  7. }
  8. @Override
  9. protected void onPostExecute(ブール結果){
  10. //起動プロセスを非表示にします
  11. WaitingDialog.dismiss();
  12. Toast.makeText(mainContext、 Submission completed !!!」 、Toast.LENGTH_LONG).show();
  13. ((アクティビティ)mainContext).finish();
  14. }
  15. @Override
  16. protected Boolean doInBackground(Object ... params ){
  17. {
  18. //フィールドからデータを取得します
  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. //コンストラクタを呼び出して、メールボックスからgmail.comにユーザー名とパスワードを渡します
  24. MailSenderClass sender = new MailSenderClass( "mypostmail@gmail.com""password" );
  25. //そしてsendメソッドを呼び出します
  26. sender.sendMail(タイトル、テキスト、 fromwhere 、attach);
  27. } catch (例外e){
  28. Toast.makeText(mainContext、 "メッセージ送信エラー!" 、Toast.LENGTH_SHORT).show();
  29. }
  30. falseを 返し ます
  31. }
  32. }
*このソースコードは、 ソースコードハイライターで強調表示されました。
すべてがシンプルで、MailSenderClassクラスのインスタンスを作成し、ユーザー名とパスワードをコンストラクターに渡します。 次に、パラメーターを指定してsendmail sendメソッドを呼び出します。

非同期プロセスは、onPreExecute()、doInBackground()、およびonPostExecute()の3つのメソッドで構成され、これらは記述された順序で実行されます。

それを使用する方法を忘れた人のために、ここにコードがあります:





  1. public void onClick(View v){
  2. sender_mail_async async_sending = new sender_mail_async();
  3. async_sending.execute();
  4. }
*このソースコードは、 ソースコードハイライターで強調表示されました。


したがって、小さなストリームクラスを作成すると、クライアントからメールボックスに必要な情報を安全に送信できます。



アプリケーションのソースコードは、 ここからダウンロードできます



All Articles