Fix possible crash when detached from activity.

There were a couple places where an AsyncTask expects an Activity to still
be available, when it may no longer be.

Bug: 72818
Change-Id: Id2e4a17148f794b6db9c459d7a29c8c8c34d99f9