iammert / RadioPlayerService

Android service library which uses AAC Player. Ready to use Radio Player Service.
254 stars 91 forks source link

How to detect when CANCEL is clicked #40

Closed gigi199596 closed 7 years ago

gigi199596 commented 7 years ago

Hello,

I want to detect when the cancel button inside the player is pressed to close the app in background... Does someone have a clue?

Thanks a lot!

gigi199596 commented 7 years ago

Because I always search when I need something, here is the solution :p for those who wants. So they can stop the app after. In RadioListener.java, add:

void onRadioClosed();

in RadioPlayerService.java, add:

private void notifyPlayerClosed() { 
        for (RadioListener mRadioListener : mListenerList) {  
            mRadioListener.onRadioClosed();
        }
    }

in function stopFromNotification() inside the same java file, add:

notifyPlayerClosed();

after:

stop();

That's all :+1: