I'm playing around with notifications on a Fire TV. I have a timer which calls the following sub to periodically produce a notification. I can leave my app and enter other apps and the notifications continue to be displayed. However, if I play a video, e.g. with the YouTube app, then the notifications stop being displayed. Stopping the video and returning to the YouTube video browser, the notifications start being displayed again. Identical behaviour happens in other video playing apps. It would appear that the notifications don't have sufficient priority to display over a playing video. I'm using the HIGH priority notification (as you can see in the below code) and the Amazon documentation seems to suggest that is all that is required to display the heads-up notifications.
B4X:
Sub Simple_Notification
Dim n As NB6
n.Initialize("default", Application.LabelName, "HIGH").SmallIcon(smiley)
n.Build("Title", "#" & cnt, "tag1", Main).Notify(4)
cnt=cnt+1
End Sub
Other third-party (not just Amazon) apps are able to display notifications over YouTube videos, e.g. "Notifications for Fire TV". Any idea where I'm going wrong?
Yes, the logs show the notifications being produced. It does use a foreground service. I have a count (the cnt in the above code) whose value correctly increases corresponding to the time that the video is being played and the notification are not being shown.
I posed the question to the developer of "Notifications for Fire TV", the app I mentioned that does manage to display notifications over playing videos, and he has just responded saying that he used an api that no longer exists and he believes that it is no longer possible. I have asked him for more details.
Just realised this has nothing to do with Fire TV, I see almost exactly the same behaviour on regular phones. The only difference is that on a phone I hear the notification sound and on the Fire TV I don't.
So the question I should have asked is: is it possible to display a notification over a video playing full-screen?
I have confused myself, there seem to be two behaviours that I have mixed up.
1. The Fire TV issue as described in the first post is still present. The developer I mentioned in my last post has told me that the app needs to have the SYSTEM_ALERT_WINDOW permission in order to display notifications over playing videos. The Fire TV no longer seems to allow that permission to be set (I tried) so I can't test to see if the permission fixes the problem. Not sure where to go from here.
2. I am seeing a weird notification behaviour on regular android devices. I'll create a new question about that one but basically I find that after dismissing (swiping) a notification, no new notifications are displayed for one minute.