So, the following code
if (data.isEmpty()) {
gives:
Error: Array Out Of Bounds Error
when it's "Lang.Dictionary {size: 0}"
Similarly,
if (data.size() == 0) {
Also gave the same error.
So what can I do to test its size so it doesn't crash?!?
So, the following code
if (data.isEmpty()) {
gives:
Error: Array Out Of Bounds Error
when it's "Lang.Dictionary {size: 0}"
Similarly,
if (data.size() == 0) {
Also gave the same error.
So what can I do to test its size so it doesn't crash?!?
The var type = data.keys()[0];
was from the original developer. I assume he was expecting just one web request data to be returned at a time but I now piggy back two of them together. I'm now iterating…
If it's not 200 it will be null in many cases/devices, but in that case, onBackgroundData won't be called so your main app doesn't see it.
Your best option would be to use a try / catch for Application.ObjectStoreAccessException.
If it's not 200 it will be null in many cases/devices, but in that case, onBackgroundData won't be called so your main app doesn't see it.
Background.exit
Search the forum, you'll find as I and others have that this is glitchy. Do not assume it will happen, consider using application storage.
Writing to application storage for background processes isn't available for older models.
Writing to application storage for background processes isn't available for older models.
That's true, devices before CIQ 2.4 don't have it, but devices before CIQ 2.3 don't have background. There aren't any 2.3 devices, there's a gap between 2.2 and 2.4 so all devices have either both or neither.
Oh, that I didn't know. Si why did Garmin take the time to mention that? It only confuses for no good reason!
Actually, for Application.Storage, it's CIQ 3.2 for setValue.
See forums.garmin.com/.../f5-can-t-save-to-storage-from-background-while-f6-and-others-can
I'll stick with Background.exit then...
I've pretty much had one or more apps with a background service running on every device I've used since backgrounding was introduced, and never had any issue with Background.exit. You can run into problems if you are trying to pass back too much data or the wrong type of data, but that I consider a bug in the app itself.
Actually, for Application.Storage, it's CIQ 3.2 for setValue.
I read that as CIQ 3.2 for background, but the API docs say 2.4 otherwise. Great. Another argument for "has".
Actually, for Application.Storage, it's CIQ 3.2 for setValue.
See forums.garmin.com/.../f5-can-t-save-to-storage-from-background-while-f6-and-others-can
Actually, the requirement is CIQ 3.2 for Storage.setValue() from a background process. For non-background processes, the requirement is CIQ 2.4.
This is explicitly called out in the docs for Storage.setValue(), getValue(), deleteValue() and clearValues(), likely as a direct result of that bug report.
Here's the deleteValue() doc. The docs for setValue() and others is similar, in the sense that they all say "Since: API Level 2.4.0" but they also note that "ObjectStoreAccessException" is thrown from a background process on a device without 3.2.0 support. I chose deleteValue() for the screencap bc it's the doc with the least amount of text.