0

I'm trying to create a complication for Wear OS and having problem trying to add the icons, I'm using ShortTextComplicationData which can be combine with an Icon, according to the documentation Here.

here is the current code

private fun createComplicationData(text: String, contentDescription: String): ShortTextComplicationData {
val complicationData = ShortTextComplicationData.Builder(
    text = PlainComplicationText.Builder(text).build(),
    contentDescription = PlainComplicationText.Builder(contentDescription).build()
)
return complicationData.build()

}

this code works correctly but I have no option to add an image, ShortTextComplicationData says I need to use a MonochromaticImage.

I tried working with this line complicationData.setMonochromaticImage(???).build()) but I don't have a MonochromaticImage to add or how to create it.

not sure if going in the right direction, any help will be appreciated!

kimosavi
  • 41
  • 5

1 Answers1

0

I solved my problem by adding the following code

val icon = IconCompat.createWithResource(this.baseContext,R.drawable.ic_sense_white).toIcon(this.baseContext)
complicationData.setMonochromaticImage(MonochromaticImage.Builder(icon).build())

the IconCompat help create the Icon then i can pass this to the complication data.

kimosavi
  • 41
  • 5