What is this guard meant to protect against?  I don't see any code path where activity == null is possible.