RadioPlayerService
RadioPlayerService copied to clipboard
help needed using updateNotification
Hello,
Can you add to documentation how to use updateNotification, because I tried a lot of things and there is no way to update the content of the notification !
I really appreciate any help you can provide.
Hi,
There is a method in RadioManager class that handles content of notification changes.
updateNotification(String textHeader, String textSub, Bitmap artImage)
or
updateNotification(String textHeader, String textSub, int artImage)
You can use one of them like that;
private void updateNotification(String stationName, String trackInformation) {
Bitmap bitmapTrackImage = ((BitmapDrawable) imageViewBottomCover.getDrawable()).getBitmap();
radioManager.updateNotification(stationName, trackInformation, bitmapTrackImage);
}
if you have still problem about this, Can you share your code snippet to understand the problem better.
Thanks for you answer but it doesn't work. I'm on 4.4.2
I do like that :
public void playRadio(RadioItem radioStation) {
mRadioManager.startRadio(radioStation.getRadiourl());
Bitmap bitmapTrackImage = imageLoader.getBitmap(radioStation.getRadioImageurl());
mRadioManager.updateNotification(radioStation.getRadioName(), "", bitmapTrackImage);
}
EDIT:
I noticed that if I invert the startRadio and updateNotification my custom notification is replaced by the default one, and no way to edit it again.
EDIT2:
I temp fixed my problem like that :
@Override
public void onMetaDataReceived(String s, String s1) {
Bitmap bitmapTrackImage = imageLoader.getBitmap("url");
mRadioManager.updateNotification("test", "", bitmapTrackImage);
}
but play/pause button doesn't change anymore and if I close the notification I can't restart player.
I really appreciate any help you can provide.
Hi, Yeah One way to update your notification content that you can use onMetaDataReceived. But this callback method continuously feeding by the system itself. So be carefull when you use this method update your UI or notification content since you may end up serious UI performance problems.
Speaking of closing notification issue, I will investigate it, if there is a problem on the class itself, update it ASAP.
Having a similar problem here with the updateNotification method. I'm trying to update the notification content on the onRadioConnected method but it doesn't work. I believe that the notification icon for play/pause isn't updating properly as well. If I pause the radio on the main activity, notification UI does not update. I'm really stuck. Help plz!!
Just figured out what was happening! I wasn't declaring the "mRadioManager" variable as a private field. When I changed it, the updateNotification method started to work. I also updated the project with the jitpack most recent build, and now I'm able to change the small icon (play/pause) in the notification.