Switching activities, creating events, sending emails
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("message/rfc822");
intent.putExtra(Intent.EXTRA_SUBJECT, "Subject");
intent.putExtra(Intent.EXTRA_TEXT, "Message");
intent.putExtra(Intent.EXTRA_EMAIL, new String[]{"ishan.narula@gmail.com"});
startActivity(Intent.createChooser(intent, "Choose an email client from..."));
- Add READ_CALENDAR and WRITE_CALENDAR permission to manifest
Calendar startTime = new GregorianCalendar(2016, 0, 17, 13, 30);
Calendar endTime = new GregorianCalendar(2016, 0, 17, 14, 30);
Intent intent = new Intent(Intent.ACTION_EDIT);
intent.setType("vnd.android.cursor.item/event");
intent.putExtra(CalendarContract.Events.TITLE, "Event Title");
intent.putExtra(CalendarContract.Events.EVENT_LOCATION, "Event Location");
intent.putExtra(CalendarContract.EXTRA_EVENT_ALL_DAY, false);
intent.putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, startTime.getTimeInMillis());
intent.putExtra(CalendarContract.EXTRA_EVENT_END_TIME, endTime.getTimeInMillis());
startActivity(intent);
Intent switchIntent = new Intent(getApplicationContext(), DesiredActivity.class);
startActivity(switchIntent);
//passing data between activities
FIRST ACTIVITY
String data = "hello";
switchIntent.putExtra("KeyName", data);
SECOND ACTIVITY
String message = getIntent().getExtras().getString("KeyName");