Merge "Do not set activity's task before clearing in some scenarios." into pi-dev