1

I'm trying to make a WearOS Complication that is just an image. Ideally, it should display the image img1.png when on like this, and the image outlines.png when in ambient mode like this.

Right now, I've got

return when (request.complicationType) {

        ComplicationType.SMALL_IMAGE -> SmallImageComplicationData.Builder(
            smallImage = SmallImage.Builder(
                Icon.createWithResource(this, R.drawable.img1), SmallImageType.PHOTO).build(),
            contentDescription = PlainComplicationText
                .Builder(text = "Sample text").build()
        )
            .setTapAction(complicationPendingIntent)
            .build()

        else -> {
            if (Log.isLoggable(TAG, Log.WARN)) {
                Log.w(TAG, "Unexpected complication type ${request.complicationType}")
            }
            null
        }
    }

and I want to add the ambient image somewhere but don't know how. This code sample is inside the onComplicationRequest function, which returns ComplicationData? by the way. I have the same issue with

override fun getPreviewData(type: ComplicationType): ComplicationData {
    return SmallImageComplicationData.Builder(
        smallImage = SmallImage.Builder(
            Icon.createWithResource(this, R.drawable.img1), SmallImageType.PHOTO).build(),
        contentDescription = PlainComplicationText
            .Builder(text = "Your loved one's images!").build()
    )
        .setTapAction(null)
        .build()
}

which again, returns ComplicationData. Any ideas? Thanks! (The documentation for WearOS development is pretty incomplete imo :P)

Marvil
  • 17
  • 4

1 Answers1

0

It's on SmallImage.Builder

https://developer.android.com/reference/androidx/wear/watchface/complications/data/SmallImage.Builder#setAmbientImage(android.graphics.drawable.Icon)

Try

        SmallImageComplicationData.Builder(
            smallImage = SmallImage.Builder(
                Icon.createWithResource(this, R.drawable.img1), SmallImageType.PHOTO)
              .setAmbientImage(...)
              .build(),
            contentDescription = PlainComplicationText
                .Builder(text = "Sample text").build()
        )
            .setTapAction(complicationPendingIntent)
            .build()
Yuri Schimke
  • 12,435
  • 3
  • 35
  • 69