title: Create event listener for 'Set' button of DatePicker dialogue
body: <p>I'm working on this android application in which user clicks on pick date button and the date picker dialogue box pops up, user can set the date and press the set button of the dialogue box. I am not able to get the event listener behind set button. I want to get the date user has set in that dialogue box behind that set button.</p>
  
  <pre><code>@Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_locations);
  
  
          pickBtn = (Button) findViewById(R.id.pickDateButton);
            final Calendar c = Calendar.getInstance();
              year  = c.get(Calendar.YEAR);
              month = c.get(Calendar.MONTH);
              day   = c.get(Calendar.DAY_OF_MONTH);
  
              month = month + 1;
  
          pickBtn.setOnClickListener(new View.OnClickListener() {
              @SuppressWarnings("deprecation")
              @Override
              public void onClick(View v) {
                  showDialog(DATE_PICKER_ID);
  
              }
          });
  
      }
  
      private DatePickerDialog.OnDateSetListener datePickerListener = new DatePickerDialog.OnDateSetListener() {
  
          // when dialog box is closed, below method will be called.
          public void onDateSet(DatePicker view, int selectedYear,
                  int selectedMonth, int selectedDay) {
              Toast.makeText(getApplicationContext(),"fdf",
                         Toast.LENGTH_LONG).show();
              Toast.makeText(getApplicationContext(), "Tracking Stopped",
                         Toast.LENGTH_LONG).show();
              year = selectedYear;
              month = selectedMonth;
              day = selectedDay;
  
          }
      };
  </code></pre>
  
  <p>Have i wrote the right listener? it's not displaying the toast message inside the listener so its not coming inside it when user presses set button and closes the dialog.</p>