由于没有窗口焦点,Android活动没有响应触摸事件Dropping事件

时间:2016-08-25 09:21:52

标签: android material-design activity-transition

活动A为结果启动活动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);

然后在活动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后,活动A在日志中变得不可触及:

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上进行测试

2 个答案:

答案 0 :(得分:3)

在活动B中替换

            finish();

通过

            finishAfterTransition();

似乎解决了这个问题。 以某种方式,活动A保持mPausedForTransition=true暂停,等待从未发生的过渡动画,除非你拨打finishAfterTransition

答案 1 :(得分:-1)

你需要尝试像

这样的东西
activity.requestFocus();