How can a watchface display an image downloaded in the background by makeImageRequest?

The subject really says it all. I'm successfully downloading an image using makeImageRequest in a background process. I believe the image is stored in the graphics pool, and the background process has a reference to it as a Graphics.BitmapReference.

How then can I access this image from the main watchface view?  I can't used Background.exit() to return the BitmapReference since it isn't one of the allowed types for exit(). It should be obvious how to do this, but I can't see how.

Thanks in advance for any help.

Michael

  • Welcome to CIQ development!!!1!

    Yeah, seriously, it's a bit of pain. It doesn't help that ppl tend to assume that an issue they encountered years ago has never been fixed (it's understandable bc lots of stuff goes unfixed for years or forever).

    Also, the API documentation being wrong makes it difficult.

    Yeah I'm fairly sure the api doc and typecheck info are generated from the same source, so it's no surprise to me that both of them are wrong in the same way (it's happened before). At least it's better than the alternative: the docs saying one thing and the type check data saying something else.

    Anyway, here's the bug report:

    [https://forums.garmin.com/developer/connect-iq/i/bug-reports/application-storage-setvalue-s-2nd-argument-value-is-not-typed-or-documented-to-take-a-bitmapreference-but-it-should-be]

  • It would be much simpler if Garmin  allowed a BitmapReference to be returned using Background.exit(). Then there would be no need to use Application.Storage

  • Thanks for that, great bug report.

    Everyone reading this, please visit the bug report and vote it up.

  • TLDR; but it seems you guys already got it working. It was a struggle to get this system working, but glad it's all good now! Have a great one! 

  • Upvoted the bug report.  Thanks for logging it.

  • This is now working in the "System 8 Preview Device" in the SDK 8 beta. It has firmware version 5.1.0, so I hope this gets rolled out to all current 5.0 devices.

  • I'm pretty sure some devices already have beta FW with 5.1.0, but won't be available for them in CIQ until there's a non beta SDK for them.  In the past, there have been up to 3 beta SDKs before a production one, and it's taken some time.  With the beta SDKs you can't build an iq file, so for testing you need to build a sideload, with the -disable-api-has-check-removal compiler flag so has is resolved at run time, and not compile time.

    In the readme file in the SDK you can see how many beta SDKs for different versions.

  • I think you read too much into what I said. Something Garmin broke with the release of CIQ 4 seems will be fixed with CIQ 5.1. All the CIQ 4 devices were updated to CIQ 5.0, so I'm hoping all the devices that are now 5.0 will become 5.1. I get nothing is guaranteed, and rolling out firmware updates for many devices may take a while, but any watchface which used makeImageRequest in the background in CIQ 3 will now work again without any code changes. I'm going to call that a win.

  • I think you read too much into what I said. Something Garmin broke with the release of CIQ 4 seems will be fixed with CIQ 5.1. All the CIQ 4 devices were updated to CIQ 5.0, so I'm hoping all the devices that are now 5.0 will become 5.1. I get nothing is guaranteed, and rolling out firmware updates for many devices may take a while, but any watchface which used makeImageRequest in the background in CIQ 3 will now work again without any code changes. I'm going to call that a win.

    Can you clarify exactly what situation isn't working in CIQ 4 and has now been fixed in CIQ 5.1?

    The bulk of the preceding replies are all about how makeImageRequest actually does work in the background on CIQ 4+ devices, if you call Application.Storage.setValue() on the resulting bitmap reference, as long as you:

    - don't call get() on the reference

    - don't try to use instanceof BitmapReference

    - either disable the type checker or add a cast to work around the type check issue (the fact that the type checker thinks Application.Storage.setValue() won't work with a BitmapReference is the focus of the bug report I mentioned)

    Note that it should be possible for the same code to work on either a bitmap or a bitmap reference that's returned from makeImageRequest (meaning the same code could work on both CIQ 3 and CIQ 4+ devices)

    e.g. https://pastebin.com/cfFBixeh

  • I'm not sure how to make "makeImageRequest" works in the background now in 5.1 when it didn't in 5.0 any more clear. Sounds like you yourself have never tried to use makeImageRequest in the background on a watchface with a CIQ 4 (now CIQ 5.0) device, or you would know. You will get this on a CIQ 5.0 device:

    Error: Exception occurred
    Details: failed inside handle_image_callback
    Exception: Class usage is not allowed for the current app type.

    The code I have works for CIQ 3.x devices and now CIQ  5.1 devices with no changes. Nobody has code with makeImageRequest that works for CIQ 4.0 through CIQ 5.0. It's not allowed in a watchface anymore than access to GPS or a few other sensors. If you have makeImageRequest code working in the background of a watchface of your own we would all love to see it.