@Override public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); switch (id) { case R.id.map_all_classes: // check to see if we're done loading the schedules (the // ScheduleClassAdapter is initialized in onPostExecute) if (adapter != null) { // populate an array with the buildings IDs of all of the user's classtimes ArrayList<String> buildings = new ArrayList<String>(); for (UTClass clz : classList) { for (Classtime clt : clz.getClassTimes()) { if (!buildings.contains(clt.getBuilding().getId())) { buildings.add(clt.getBuilding().getId()); } } } Intent map = new Intent( getString(R.string.building_intent), null, parentAct, CampusMapActivity.class); map.putStringArrayListExtra("buildings", buildings); startActivity(map); break; } case R.id.export_schedule: // version-gate handled by xml, but just to make sure... if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { // check to see if we're done loading the schedules (the // ScheduleClassAdapter is initialized in onPostExecute) if (adapter != null) { FragmentManager fm = parentAct.getSupportFragmentManager(); DoubleDatePickerDialogFragment ddpDlg = DoubleDatePickerDialogFragment.newInstance(classList); ddpDlg.show(fm, "fragment_double_date_picker"); } } else { Toast.makeText( parentAct, "Export to calendar is not supported on this version of Android", Toast.LENGTH_SHORT) .show(); } break; default: return super.onOptionsItemSelected(item); } return true; }