Launching Collect from a browser

Ivan from HOT here; we're interested in launching a specific ODK form from a browser!

Background

We're basically implementing a sort of Tasking Manager workflow for field data collection using ODK. For those of you familiar with the HOT Tasking Manager this should make sense! The basic idea is breaking a large Area of Interest into small chunks to allocate to individual field mappers, leveraging the App User/Form Access functionality of Central for the allocation and the new Select from File (map) feature to represent the task area.

Here's a blog post describing the idea, and a webinar in which we demonstrated some of the prototype components (which, to our great delight, @yanokwa attended and contributed to). Some code for the prototype Field Mapping Tasking Manager (FMTM) can be found here.

What we are trying to do

One bit we're not sure how to implement is launching a specific ODK form from the FMTM. Basically we want the field mapper to select an area/task on a Web map, and quickly end up within ODK with the relevant App User/form/map file cued up. I'm re-animating this venerable thread because it's the only reference I can find on the forum that seems to speak to the idea of launching directly from a browser.

What works now

At the moment, a workflow that does the job is:

  • The field mapper selects an area on a Web map. A popup appears with a QR code.
    • If the web map is displayed on a separate device (a computer, or someone else's phone), the field mapper opens ODK Collect, scans it, and proceeds. However, generally speaking we don't expect field mappers to be carrying a laptop, or to have a colleague with another phone/device next to them. They are mostly likely looking at the Web map on the same phone/device that they are using to fill out the form using ODK Collect.
  • From their own phone, they can:
    • Long-press on the QR code and select Download image
    • Open ODK Collect, hit the colored-circle-with-a-letter-in-it project button on the upper right, select Add project
    • Click the kebab menu on the upper right, select Import QR code (seems to be the only option in that menu)
    • On the devices we've tested, the resulting dialogue defaults to displaying "Recent images," with the freshly-downloaded QR code as the first (upper left) option. Upon selecting it, ODK Collect switches immediately to the desired project and form.

Thats ok, but it's not awesome. There are two main drawbacks:

  1. From the "Add project" dialogue, it's not obvious that the kebab menu allows importation of a QR code that's locally saved as an image, and
  2. The whole process seems like a fair number of button presses.

What we'd like

It would be delightful if the field mapper could simply click on a Web map, see an ODK icon with a human-readable project ID, click it, get an Android notification along the lines of "Open this link with..." (with ODK Collect as an option, ideally the default or configurable as such) and rock on.

The above solution—launching from form already found in the instances directory—seems like something we could build upon. However, it seems like it has a few drawbacks:

  • The form must already be present in the instances directory on the field mapper's phone
  • I'm not sure if this handles other options, such as basemap (we want an OSM/Mapbox basemap rather than Google) that the QR code handles so admirably.

The ask

If anyone has any ideas how to either streamline the process of configuring from a QR code viewed in a browser on the device running ODK Collect, or launching ODK Collect with a similar configuration payload directly from a Web resource, we'd be grateful to hear about it!

Onward,
Ivan

1 Like

You might be able to launch apps by intent from the web but I'm not sure whether that's still possible. You could then use the undocumented intent to specify a server URL and form_id and launch that in Collect (I could write up some details if you validate that intents work and that seems interesting). The downside is that there has to be one project (e.g. the demo project) in Collect for this to work (see this thread).

We explored launching Collect with a configuration URL a while back but didn't see a good way to get a config in.

1 Like

Hi LN,

Your idea with intent filters sounds like the best solution, via deep linking.

As ODKCollect now accepts a base64 encoded QR code, could a URL configuration be provided via the base64 encoded string in a query parameter?

Example link:
app://odkcollect?qr=base64encodedqrcodestring

Example code:
Uri data = intent.getData();
data.getQueryParameter("qr");

Ref: https://developer.android.com/training/app-links/deep-linking

Would there be any interest in a contribution for this feature?