Importing String(s) from External App, Measuring LUX / Light Intensity

1. What is the issue? Please be detailed.
I have not yet embarked on the journey to get a string into ODK Collect from an External App, but I wanted to know if anyone else has used Collect to obtain light intensity data measured in LUX.

Currently surveys are done for newly planted trees and one of the biggest and most important things that changes over the year is light exposure. Not only does this change depending on the time of day, but from season to season the sun angles change and we're managing our trees in such a way that we are not clear cutting the savannah, but rather keeping native trees to provide partial shade and there are very large differences even as small as 1m away.

Right now I just have a survey question that is a rank from 1-5, but I'm worried it's too subjective for whoever is doing the survey. Even the same person over time is unlikely to be as consistent as what I'd want in the same conditions. Ideally an enumerator would be able to press the button to launch an external app which collects a min, max, and average LUX value.

Here is the app I've used in the past for measuring LUX:

In the help section of the app it says: "You can share your measurements into another app if you want to."

2. What steps can we take to reproduce this issue?
Using the form I can successfully launch a text question into the external app.
I then can move my phone around to get LUX values and press Store, type a string, then ok, then press the recall button, highlight my lux value, tap share, but ODK doesn't come up. I'm able to copy the values to the clipboard and this is what is returned:

----------------
10 LUX
test
12/23/24   10:44 AM
----------------

3. What have you tried to fix the issue?
I looked at the ODK Documentation and found this but the counter app looks like its no longer available or the link has been changed. I don't really understand the code with regards to "intent"

I'm not sure what is provided on the app side of things is compatible, but I've emailed the app creator and shared this forum post, maybe they can chime in here, but no guarantees, or maybe others have used other apps for measuring light intensity and connected them to Collect?

4. Upload any forms or screenshots you can share publicly below.
Time_Example.xlsx (9.9 KB)

Hi @Tyler_Depke

I believe the link should be updated and refer to https://github.com/getodk/counter/blob/master/app/src/main/java/org/opendatakit/counter/activities/CounterActivity.kt#L159

ODK Collect does not use the Android Share mechanism you mentioned. Instead, it expects the external app to return a key-value pair where the key is "value" and the value is whatever data the app needs to return. This pattern is not commonly used in the Android ecosystem; it’s a design choice specific to how ODK surveys handle interactions with external apps. As a result, apps launched by ODK Collect must be built with this specification in mind and handle it correctly. Since this approach isn't widely adopted, most apps are specifically created to work with ODK Collect, and the one you referred to doesn’t appear to be one of them.

I'll take a look to see if integrating the Share mechanism would make sense in Collect. For now, however, you could consider using two questions: one to launch the external app and another to manually enter the recorded value.

1 Like