TEMPERATURE Error - Edge Device

I'm SO close, but yet...

This works perfectly as a CIQ application on my Edge 820 device. When I convert it to a datafield (change the manifest type and the two lines shown), then I get a compile error that I need to add Background persmissions. Ok, I do that and it compiles fine. When I run it in the simulator or on my device, I get the "IQ" splashscreen abort. With the logs shown in the image at the DropBox link. I could not upload the image here for some reason.

Any ideas? Did Garmin just decide a datafield isn't allowed access to the internal temp sensor?


https://www.dropbox.com/s/jiegxfruzqxrjq0/TEMP-error.jpg?dl=0
  • Edge devices are odd, as the internal temp is available in Sensors. On other devices, that's the Tempe if paired. On other devices, you can use SensorHistory.

    With SensorHistory, you just need that permission and you can access things in the main process.

    With the Edge and a data field, you need to have the background permission as well as the Sensor permission, but you can only access Senor in a background process. So, you need to set up a background process, with something like a 5 minute temporal event. That process can be fairly simple, in that it just gets the temperature from Sensor and returns it with Background.exit(), and then in your Appbase, get it with onBackgroundData().

    You're trying to access Sensor in the main process. That's why you have the permission problem.
  • Here's a Blog Post I did with the basics of backgrounding, and an associated forum thread.

    It's a basic watch face, but the principles are the same for other app types.

    One thing about DFs, but may not be an impact for you, is once you register a temporal event, it runs 24/7, so by default, it will run even if the DF isn't being used. You can do things like delete the temporal event in onStop() if that's being run by the main app. (there's a trick to see if the background is calling onStop() and maybe have the hook in the sample I posted - I forget - I wrote that a while back)
  • Wow!! You are truly a MASTER. Thank you!!

    I do wish Garmin would simply add temperature and gradient to the Activity.Info structure. Would make life much easier for us.
  • You know what would be SUPER cool... is a DF that launches a background process that first tries to get the local weather via a comm process via the attached smart phone. and if that isn't successful, then uses the internal temp sensor.

    what I don't know is how to use the gps coordinates from my garmin device to ask a web service for the temp at my current location, and get the elevation of the web-based temp reading, so I can then adjust the temp based on the actual elevation I'm at (eg: cycling up a tall mountain).
  • I have an unpublished DF that does get the internet weather, but for it, I just display the last reading and not switch to the sensor. That's a case where I want to delete the temporal event in onStop(), as there's no point in getting the data when the DF isn't running.