I want to add a upper limit to my date picker (spinner). The max date should be "today". I tried to add this line of code but then my app crashes:
dpDate.setMaxDate(new Date().getTime());
Here's the whole code, can anybody see what's wrong? :)
addToCal.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
final AlertDialog.Builder mBuilder = new AlertDialog.Builder(Activity4.this);
View mView = getLayoutInflater().inflate(R.layout.dialog_add_call,null);
final DatePicker dpDate = (DatePicker)findViewById(R.id.dpDate);
dpDate.setMaxDate(new Date().getTime()); //this makes the app crash
mBuilder.setView(mView);
final AlertDialog dialog = mBuilder.create();
dialog.show();
}
});