Android activity 没有响应触摸事件由于没有 window 焦点而导致掉落事件

Android activity not responding to touches event Dropping event due to no window focus

Activity A 开始 activity B 的结果:

 Intent intent = new Intent(ActivityA.this, ActivityB.class);
                    ActivityOptionsCompat transitionActivityOptions = ActivityOptionsCompat.makeSceneTransitionAnimation(NewInvoiceActivity.this);
                    Bundle b = transitionActivityOptions.toBundle();
                    intent.putExtra("project_name", (String) projectName);
                    intent.putExtra("project_id", projectID);
                    startActivityForResult(intent, InvoiceItemSelectActivity.REQUEST_SELECT_ITEMS, b);

然后在 Activity B 中的 onCreateView 中:

        Explode e = new Explode();
        e.setDuration(400);
        getWindow().setEnterTransition(e);
        getWindow().setExitTransition(e);
        getWindow().setStatusBarColor(getResources().getColor(R.color.primary));

并在里面 Activity B 一个按钮 setOnClickListener .... :

            Intent resultIntent = new Intent();

            resultIntent.putExtra("items", "some data");
            setResult(RESULT_OK, resultIntent);
            finish();

回到A后,activityA在日志中变得不可触碰:

08-25 11:46:21.658  1481  1481 W ViewRootImpl: Dropping event due to no window focus: 
08-25 11:46:21.658  1481  1481 E ViewRootImpl: mStopped=false mHasWindowFocus=true mPausedForTransition=true

我正在 Android 6.0.1

上进行测试

你需要试试

activity.requestFocus();

在 Activity B 替换

            finish();

来自

            finishAfterTransition();

似乎可以解决问题。 不知何故 Activity A 保持 mPausedForTransition=true 暂停等待一个永远不会发生的过渡动画,除非你调用 finishAfterTransition