package com.example.habitrack;

import android.app.Activity;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.DatePicker;

public class DateSelector extends AppCompatActivity {

    DatePicker datePicker;
    Button doneButton;

    // Date vars
    Integer year;
    Integer month;
    Integer day;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_date_selector);

        datePicker = (DatePicker) findViewById(R.id.datePicker);
        doneButton = (Button) findViewById(R.id.dateDoneButton);

        doneButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                year = datePicker.getYear();
                month = datePicker.getMonth();
                day = datePicker.getDayOfMonth();

                Intent returnIntent = new Intent();
                returnIntent.putExtra("year", year);
                returnIntent.putExtra("month", month);
                returnIntent.putExtra("day", day);
                setResult(Activity.RESULT_OK,returnIntent);
                finish();
            }
        });
    }
}

@@ -1167,16 +1167,18 @@
 %22, month
++1
 );%0A     
@@ -1340,11 +1340,115 @@
 );%0A    %7D
+%0A%0A    @Override%0A    public void onBackPressed() %7B%0A        super.onBackPressed();%0A        finish();%0A    %7D
 %0A%7D%0A

add onBack function to fix bug