Android and s Ken Nguyen Clayton state University 2012
Sending s There are two main methods to send an – Via clients such as gmail or similar clients – Via SMTP/IMAP or similar services – auto ing Using client required the user have their account already setup Using the SMTP/IMAP or other service required the service properly configured – look at javax.mail package
Sending s via gmail client // MainActivity.java public class MainActivity extends Activity public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_ _main); Button send=(Button) findViewById(R.id.buttonSend); //send an when the button is click send.setOnClickListener(new OnClickListener() { public void onClick(View v) { final Intent Intent = new Intent(android.content.Intent.ACTION_SEND); Intent.setType("plain/text"); Intent.putExtra(android.content.Intent.EXTRA_ , new String[]{
Intent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Your subject"); Intent.putExtra(android.content.Intent.EXTRA_TEXT, "Your message"); MainActivity.this.startActivity(Intent.createChooser( Intent, "Send mail... – notification while sending")); } }); }
Layout.xml <LinearLayout xmlns:android=" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <Button android:layout_width="match_parent" android:layout_height="wrap_content" android:text="send " />
Exercise Create a registration activity where the user can enter their contact information and an will be sent to them as a confirmation