戻るボタンを押すまでにダイアログを表示したかったのですが、以下のコードでは実行されず、FragmentDialog が表示されません。前もって感謝します。
//BackPress
public void onBackPressed() {
TestDialogFragment test= new TestDialogFragment();
test.newInstace();
// Showing Alert Message
Log.d("Video Backpressed", "sdfdf");
}
TestDialogFragment
public static class TestDialogFragment extends DialogFragment {
public static DialogFragment newInstace() {
DialogFragment dialogFragment = new TestDialogFragment();
return dialogFragment;
}
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setTitle("TestDialogFragment");
builder.setView(getContentView());
Dialog dialog = builder.create();
return dialog;
}
private View getContentView() {
LayoutInflater inflater = getActivity().getLayoutInflater();
return inflater.inflate(R.layout.dialog_fragment, null);
}
}