when I lock my Android Screen,my app is still playing music(it means the mediaPlayer is working),but after 15 minutes,the music will be stoped,dou you know why?
(I did not use Service or BindService at all,just Use MediaPlayer Class)
when I lock my Android Screen,my app is still playing music(it means the mediaPlayer is working),but after 15 minutes,the music will be stoped,dou you know why?
(I did not use Service or BindService at all,just Use MediaPlayer Class)
Yes it happens, why?
because I think you are using MediaPlayer
in Activity
, and android release some untouched resources after some time to give space to other processes.
you have to use foreground Service to prevent this problem.
Here is example of MediaPlayer inside Service.
Release the player memory by using onDestroy() method
@Override
public void onDestroy() {
if (mp!= null) mp.release();
}