@Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); switch (item.getItemId()) { // Respond to the action bar's Up/Home button case android.R.id.home: finish(); case R.id.action_save: DatabaseHandler databaseHandler = new DatabaseHandler(AddClinicalNotesActivity.this); try { if (historyObj._date != null) databaseHandler.addHistory(historyObj); if (examObj._date != null) databaseHandler.addExam(examObj); if (treatmentOb._date != null) databaseHandler.addTreatment(treatmentOb); if (Other_Notes_Activity.otherObj != null && Other_Notes_Activity.otherObj.size() > 0) { for (int i = 0; i < Other_Notes_Activity.otherObj.size(); i++) { databaseHandler.addOther(Other_Notes_Activity.otherObj.get(i)); } Other_Notes_Activity.otherObj.clear(); } } catch (Exception e) { e.printStackTrace(); } finish(); return true; } return super.onOptionsItemSelected(item); }
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (data != null) { if ((data.getStringExtra("activity").equals("history")) && (requestCode == REQUEST_CODE)) { try { historyObj = data.getExtras().getParcelable("history_obj"); } catch (Exception e) { e.printStackTrace(); } } else if ((data.getStringExtra("activity").equals("exam")) && (requestCode == REQUEST_CODE)) { examObj = data.getExtras().getParcelable("exam_obj"); } else if ((data.getStringExtra("activity").equals("treatment")) && (requestCode == REQUEST_CODE)) { treatmentOb = data.getExtras().getParcelable("treat_obj"); } else if ((data.getStringExtra("activity").equals("other")) && (requestCode == REQUEST_CODE)) { otherObj = data.getExtras().getParcelable("other_obj"); } } }