Add check for null activity.