Prevent NPE when activity is null (refs #14).