I couldn't find any solution for the problem so I ended up using this code in the detail activity to avoid the nullpointer exception:
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
// When pressing the UP button in the action bar simulate the "back" button.
case android.R.id.home:
onBackPressed();
return true;
}
return super.onOptionsItemSelected(item);
}
At least that solution won't crash my app.