The best way and cleanest way is to override onBackPressed() in the dialog you created in onCreateDialog().
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
return new Dialog(getActivity(), getTheme()){
@Override
public void onBackPressed() {
//do your stuff
}
};
}