I want to detect whether the device is held to the user's ear or not because I want to change the audio path from the speakers to the phone's speakers (just like hearing an audio on whatsapp).
I searched about proximity and sensors but didn't find anything relevant. Is there any library I should use?