title: How to select two dates in calendar view
body: <p>I am trying to implement setOnDateChangeListener with the purpose to select two dates values (minDate and maxDate) and then use Intent to send this values to another activity. Should I store first date chosen (let say minDate) somehow and then after second click (maxDate) get value of first and send both as array or there are other ways exist to choose two dates in calendar?</p>
  
  <pre><code>        calendar.setOnDateChangeListener(new OnDateChangeListener() {
  
          @Override
          public void onSelectedDayChange(CalendarView view, int year,
                  int month, int dayOfMonth) {
  
              Toast.makeText(
                      getApplicationContext(),
                      dayOfMonth + "/" + month + "/" + year, Toast.LENGTH_LONG).show();
  
          }
  
      });
  </code></pre>
  
  <p>What I have so far is this:</p>
  
  <pre><code>            @Override
          public void onSelectedDayChange(CalendarView view, int year,
                  int month, int dayOfMonth) {
  
              Intent intent = new Intent(view.getContext(),
                      DisplayActivity.class);
  
              String year_month_dayOfMonth = String.valueOf(year) + "-"
                      + String.valueOf(month + 1) + "-"
                      + String.valueOf(dayOfMonth);
  
              intent.putExtra("date", year_month_dayOfMonth);
  
              startActivity(intent);
  
  
  
          }
  
      });
  </code></pre>
  
  <p>So, when I click on calendar date it fires DisplayActivity and only one date carried by intent. The question still remain, how to choose two dates and put them in intent.</p>
  
  <p>After intensive search I came to conclusion that date ranging in Calendar could be done only together with DatePicker. So, I select date then invoke DatePicker dialog and operate with data. Can someone confirm if my conclusion is correct.</p>
  
  <p>Have came to the following solution:</p>
  
  <pre><code>            public void onSelectedDayChange(CalendarView view, int year,
                  int month, int dayOfMonth) {
  
              int id = CalendarView.generateViewId();
  
              if ((id % 2) == 0) {
  
                  end_date = calendar.getDate();
  
                  Log.d(LOG_TAG, "End date: " + end_date + "and id = " + id);
  
              } else {
  
                  start_date = calendar.getDate();
  
                  Log.d(LOG_TAG, "Start date: " + start_date + "and id = "
                          + id);
  
              }
  </code></pre>
  
  <p>If someone will share a better solution or sample will appreciate it. Also absolutely open for any kind of criticism since a new one in Android development. </p>