They can listen in the background and Shazam will do this if you enable Automatic mode, though the iOS status bar turns red while the microphone is being accessed by a backgrounded app.
This is incorrect. They added background listening months ago.
I'm glad they haven't added this creepy feature to Android yet