It sounds like DialogFragment
might better suit your needs here. It has lifecycle methods similar to an Activity
and can run background tasks within itself, but is actually managed by the activity it is attached to. There are several types you can use.
Check out the Google documentation on it HERE.