@Override public boolean onOptionsItemSelected(MenuItem item){
  int id=item.getItemId();
  if (id == android.R.id.home) {
    onBackPressed();
    return true;
  }
  if (id == menuDoneId) {
    if (selectedImages != null && selectedImages.size() > 0) {
      for (int i=0; i < selectedImages.size(); i++) {
        Image image=selectedImages.get(i);
        File file=new File(image.getPath());
        if (file == null || !file.exists()) {
          selectedImages.remove(i);
          i--;
        }
      }
      Intent data=new Intent();
      data.putParcelableArrayListExtra(ImagePickerActivity.INTENT_EXTRA_SELECTED_IMAGES,selectedImages);
      setResult(RESULT_OK,data);
      finish();
    }
    return true;
  }
  if (id == menuCameraId) {
    captureImageWithPermission();
    return true;
  }
  return super.onOptionsItemSelected(item);
}

@ Override public boolean onOptionsItemSelected ( MenuItem item ) { int id = item . getItemId ( ) ; if ( id == android . R . id . home ) { onBackPressed ( ) ; return true ; } if ( id == menuDoneId ) { if ( selectedImages != null && selectedImages . size ( ) > 0 ) { for ( int i = 0 ; i < selectedImages . size ( ) ; i ++ ) { Image image = selectedImages . get ( i ) ; File file = new File ( image . getPath ( ) ) ; if ( file == null || ! file . exists ( ) ) { selectedImages . remove ( i ) ; i -- ; } } Intent data = new Intent ( ) ; data . putParcelableArrayListExtra ( ImagePickerActivity . INTENT_EXTRA_SELECTED_IMAGES , selectedImages ) ; setResult ( RESULT_OK , data ) ; finish ( ) ; } return true ; } if ( id == menuCameraId ) { captureImageWithPermission ( ) ; return true ; } return super . onOptionsItemSelected ( item ) ; }
handle option menu ' s click event
