Hello team,
I would like to insert a hyperlink in a form and display it only if the device is connected to internet (ODK Collect).
A calculation with some thing like
if(${network_state} = "online","You are online.","You are offline.")
Is any widget can achieve that? I can't find anything like.
Thanks for you support.
There is not a way to do exactly that inside Collect. I think it might require additional app permissions from the Android system. As a workaround, you could have a "yes/no" question that asks something like "Do have Wi-Fi or cellular data for internet browsing available right now?" and then show the link only if they answer "yes".
Note: In the demonstration above, I filled in two different submissions - one in presence of an active internet connection (it showed a URL to visit in the form), and one without internet connectivity (it showed a "no internet connection" message in the form).
Hello Dan,
Thanks for your answer, but this way of doing things forces the user to confirm whether he's online or not. The problem is that his answer could be wrong. The aim is to calculate automatically without user intervention.
Thanks
In general, I'd suggest following the workflow shared by @danbjoseph - that should be the first preference, as it's much simpler and more straightforward.
Though, here's how I implemented it on my end:
As @danbjoseph pointed out, there isn't a built-in feature in ODK Collect to achieve this directly. However, ODK Collect does support working with other external apps on the Android device via intents. So, there are two different apps involved here:
App 1 - ODK Collect:
The main data collection app.
App 2 - ODK Network Checker:
A small app I built myself.
It checks whether the device has a mean for an active internet connection and returns the result to ODK Collect when triggered.
Workflow:
When the "Launch" button is tapped in the form (within ODK Collect) - as showcased in the demo, it triggers the ODK Network Checker app in the background. That app checks for the mean for an internet connectivity and returns the result to ODK Collect, which I then used to control form logic (relevance conditions, etc.).
P.S. I didn't share the form or APK here because I wasn’t sure if sharing custom-built / random APKs is allowed on the forum ( @LN , @yanokwa - can we? ).
Hello @Yanokwa,
Thanks for you feedback.
The objective is very basic but can save a lot of time. Users are conducting surveys from multiple locations (connected or not). If the user is online, he or she will have access (from the form) to related resources stored on the cloud. For example, images, documents, etc. All this data can't be stored in the form. Making links to these resources available when the user is not online will waste a lot of time during the survey, as they will tend to open the links.
Asking the user to confirm manually may be inaccurate and/or unreliable. Users may provide incorrect information or may think they are connected.
Thanks,
Hello Minimal,
Hope you're doing fine today !
Possible to share your XLS and APK ?
If you have your APK source share on a git directory, it would be great, so I can customize.
Thanks,
Hello Minimal,
Many thanks for sharing. Don't worry, I'll put it to good use.
Thanks and thanks again, I was stuck on a question in my form, but now everything is solved and I can still improve.
Have a great day!