androidmaterial-designactivity-transition

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


Activity A starts activity B for results:

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

then in the onCreateView in Activity B :

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

and on inside Activity B a button setOnClickListener .... :

            Intent resultIntent = new Intent();

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

after returning to A, activity A becomes untouchable in the log:

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

I'm testing on Android 6.0.1


Solution

  • 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