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