I can't close softinput under certain condition
<p>If I add the deley, it works.What's the reason?</p>

<pre><code> final AlertDialog dialog0 = new AlertDialog.Builder(this)
                .setTitle("0")
                .setView(view)
                .show();
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                final AlertDialog dialog1 = new AlertDialog.Builder(TestActvt.this).setTitle("1").setMessage("222").show();

                new Handler().postDelayed(new Runnable() {
                    @Override
                    public void run() {

                        dialog1.dismiss();
                        new Handler().postDelayed(new Runnable() {
                            @Override
                            public void run() {
//                                new Handler().postDelayed(new Runnable() {
//                                    @Override
//                                    public void run() {
                                        dialog0.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
                                        getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
                                        InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
                                        view.requestFocus();
                                        imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
//                                    }
//                                },1000);
                            }
                        },100);

                    }
                },3000);
            }
        },3000);
</code></pre>