I am using a MediaPlayer
to play Media and I stop it on onPause()
(home button clicked, back, lock etc.), but on Samsung devices it is also called when they sense proximity i.e. when I want to hear the music on earpiece, it will call onPause()
and the music stops. What is the best way to handle this case? I have 2 options:
Don't stop
MediaPlayer
ononPause()
and detect a) onBackPressed(), b) Home button click, and c) lock screen. But I am not able to detect b) and c). Seems it is not allowed anymore.Stop
MediaPlayer
ononPause()
, but with some condition so that Samsung devices are also handled. The problem is I don't know what condition would be best.
Has anyone faced this? What would be the best solution?