I would like to set specific colors for events.
I believe I have to use the Calendar API. I cannot figure out how to do this.
The code I am trying is:
This is currently not possible. You can use setColor on a Calendar but not on an event. You can send feedback about the API from the developer pages about this and hope that it gets added.
Meanwhile, I suggest that you create a calendar with the desired colour and place all events in there as this will make them have that colour.