title: ActionBar's back home button is not working in fragment
body: <p>I am trying to navigate back to the previous fragment using actionbar's back button but it's not working. </p>
  
  <p>The back action works perfectly with anroid hardware back button but I also want to implement actionBar's home button.
  Here is the code: </p>
  
  <pre><code>   package com.example.eapple.tripdatacollection;
      import android.media.Image;
      import android.os.Bundle;
      import android.provider.MediaStore;
      import android.support.v4.app.Fragment;
      import android.support.v4.app.NavUtils;
      import android.support.v7.app.ActionBar;
      import android.support.v7.app.AppCompatActivity;
      import android.support.v7.widget.Toolbar;
      import android.util.Log;
      import android.util.Printer;
      import android.view.LayoutInflater;
      import android.view.MenuItem;
      import android.view.View;
      import android.view.ViewGroup;
      import android.view.inputmethod.EditorInfo;
      import android.widget.Button;
      import android.widget.EditText;
      import android.widget.ImageView;
      import android.widget.RadioButton;
      import android.widget.RadioGroup;
      import android.widget.Spinner;
      import android.widget.TextView;
  
  
      /**
       * A simple {@link Fragment} subclass.
       */
      public class AddDataFragment extends Fragment {
  
          //Tag for debugging logs
          private static final String TAG = "AddDataFragment";
  
          private Toolbar toolbar;
          private Button btnGetGpsLoc;
          private TextView tvLong;
          private TextView tvLat;
          private EditText etLocName;
          private EditText etDescription;
          private EditText etImageTitleOnCam;
          private ImageView ivAddImgBtn;
          private Spinner spnClass;
          private RadioGroup rgAccess;
          private RadioButton rbCar;
          private RadioButton rbJeep;
          private RadioButton rbTrack;
          private Button btnSave;
  
          public AddDataFragment() {
              // Required empty public constructor
          }
  
  
  
          @Override
          public boolean onOptionsItemSelected(MenuItem item) {
              int id = item.getItemId();
              if(id == android.R.id.home){
                  Log.d(TAG, "onOptionItem Selected: called");
                  getFragmentManager().popBackStack();
              }
              return true;
          }
  
  
  
  
  
          @Override
          public View onCreateView(LayoutInflater inflater, ViewGroup container,
                                   Bundle savedInstanceState) {
              Log.d(TAG, "onCreateView: Called");
              // Inflate the layout for this fragment
              View view = inflater.inflate(R.layout.fragment_add_data, container, false);
              String head = getArguments().getString("head");
  
              //Initializing objects
              toolbar = view.findViewById(R.id.app_bar_new);
              btnGetGpsLoc = view.findViewById(R.id.btn_get_location);
              tvLong = view.findViewById(R.id.tv_long);
              tvLat = view.findViewById(R.id.tv_lat);
              etLocName = view.findViewById(R.id.et_name_of_attr);
              etDescription = view.findViewById(R.id.et_description);
              etImageTitleOnCam = view.findViewById(R.id.et_cam_img_title);
              ivAddImgBtn = view.findViewById(R.id.btn_add_imgs);
              spnClass = view.findViewById(R.id.spin_classification);
              rgAccess = view.findViewById(R.id.rg_access);
              rbCar = view.findViewById(R.id.rb_car);
              rbJeep = view.findViewById(R.id.rb_jeep);
              rbTrack = view.findViewById(R.id.rb_track);
  
              //Getting reference to actionbar and doing customization
              toolbar = view.findViewById(R.id.app_bar_new);
              ((AppCompatActivity)getActivity()).setSupportActionBar(toolbar);
              ActionBar actionBar = ((AppCompatActivity)getActivity()).getSupportActionBar();
              actionBar.setTitle(head);
              actionBar.setHomeButtonEnabled(true);
              actionBar.setDisplayHomeAsUpEnabled(true);
      }
  </code></pre>
  
  <p>The onOptionsItemSelection function is not called in any case.</p>