Android Stop Background Music

前端 未结 9 974
生来不讨喜
生来不讨喜 2020-12-01 02:29

EDIT - FOUND A EASY 5-10 LINE SOLUTION!!! See MY OWN ANSWER BELOW!!! YAY!!!!!!!!!

I\'ve searched for 5 hours, dozens of SO posts, no answers, and this seems like t

9条回答
  •  臣服心动
    2020-12-01 02:39

    For those still looking for a solution in lollipop or just without using permission thing, I came up with another solution as last resource. We can measure the time user has been afk. If it was more than X ms, then you can consider he left the application and stop the music.

    So I'm using Application child where I store the time afk and BaseActivity to override onPause and onResume of all my activities.

提交回复
热议问题