3

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:

  1. Don't stop MediaPlayer on onPause() 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.

  2. Stop MediaPlayer on onPause(), 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?

Ankit Aggarwal
  • 787
  • 1
  • 9
  • 15
  • hi..i had the same problem, [this could help](http://stackoverflow.com/questions/35318649/android-proximity-sensor-issue-only-in-samsung-devices/37508973#37508973) – Pararth May 29 '16 at 10:50
  • @user2450263 Haven't gone through the link. But would I need to implement all 3 points, or 1 of them? – Ankit Aggarwal May 30 '16 at 06:03
  • you could use the first one..move your functions from onPause() – Pararth May 30 '16 at 09:15

0 Answers0