1

活动 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);

然后在 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 后,活动 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 上进行测试

4

2 回答 2

4

in Activity B replacing

            finish();

by

            finishAfterTransition();

seems to solve the issue. somehow Activity A keeps mPausedForTransition=truepaused waiting for a Transition animation that never happens,unless you call finishAfterTransition

于 2016-08-26T04:23:04.913 回答
-2

你需要尝试类似的东西

activity.requestFocus();
于 2016-08-25T09:23:43.080 回答