Reputation: 2657
I have a data application (a drawing app), and I would like to use the supposed built-in functionality of the CastCompanionLibrary to put up a notification whenever the application is not visible, but it is still casting.
I have the following in my "onResume":
mDataCastManager = DataCastManager.initialize(context, APPLICATION_ID, NAMESPACE);
mDataCastManager.enableFeatures(DataCastManager.FEATURE_NOTIFICATION |
DataCastManager.FEATURE_LOCKSCREEN |
DataCastManager.FEATURE_DEBUGGING);
// ...snip...
mDataCastManager.incrementUiCounter();
and the following in my "onPause":
mDataCastManager.decrementUiCounter();
however, not notification shows up. What do I need to do differently? I can't find anything in the docs, and I can't make sense of the source. I don't see anywhere in the source where notifications are handled at all, actually. What am I missing?
Thanks!
Upvotes: 1
Views: 198
Reputation: 19084
DataCastManager
doesn't have any built-in notifications since the nature of data-centric application can vary greatly so what should be shown there in the notifications is by no means clear. In those cases that I needed to define one, I followed the following steps:
VidoCastNotificationService
and copy that and create your own version of it, say MyDataNotificationService
. There, you can define how your notification should look like, what PendigIntents
you need to call, etc. Most of the code should be the same.DataCastManager
. That class is again very generic for the very same reason, so you need to subclass it and add your own logic whenever it needs. In there, write a method called, say, startNotificationService
by looking at what the similar method does in VideoCastManager.There are some other things that you need to do in your subclass that can be very useful but that is a very high-level outline. I have done this for a slideshow app but is not 100% complete yet and recently have been very busy with some other more pressing activities; hopefully at some point (not too far in future) I can get a chance to complete and open source that so folks can have one way of doing what I had outlined above; meanwhile try your own version and ask questions if you run into issues.
Upvotes: 2