Send data from external app to odk collect

Good day everyone,

I'm new using the ODK platform, and I would like to get your support.

I have an android application, and I would like to send some data to a selected form in ODK Collect.

Please explain me how can I do the below.

  1. Select a specific form in ODK Collect
  2. Send data to the specific form.

Thanks in advance.

Welcome to the ODK forum, @Jesse_Issufo! We're glad you're here. When you get a chance, please introduce yourself on this forum thread. I'd also encourage you to add a picture as your avatar because it helps build community!

What have you tried so far? Have you read the documentation on Launching External Apps from Collect?

Hi @danbjoseph,
I'm trying to open ODK Collect from my external android app, load a specific form with data pre-loaded by my external app.

I read the documents but didn't find a solution
I know I have to use 'Intent' but I want to know how to choose a form and pre-load it with data.

Hi @danbjoseph
Anything?

Most use cases I've heard involve starting a survey form in ODK, launching an external app to do something and then passing the data back into ODK and continuing with the survey. I'm not familiar with a workflow that starts in an external app. And I'm not familiar with how to integrate Collect and other apps. You might try searching the #development category for threads that discuss something similar.

See documentation.

This can no longer be done. It used to be possible through the filesystem but because of changes to Android this is no longer possible. There are currently no plans to replace this. It would be helpful to understand your underlying need and workflow to see whether there might be alternatives you could consider.

Thank you @danbjoseph and @LN for your responses.
I'll try to find a workaround for what I want to do.

1 Like

Hello here! I just came across this thread as we may have a similar need. We don't need any pre-filling so that's fine, however the main concern with the documented flow is that the intent URI to invoke, e.g. content://org.odk.collect.android.provider.odk.forms/forms/2 in the example from the doc, uses a form id (2) that seems to be local to the ODK app instance, meaning it will be different on each device, even for the same server form.

Is there no way to directly invoke a specific form using some "global" id (e.g. the one from the server, or from the form's settings tab), rather than having to first look it up locally? It seems that the ODK app should be able to perform this lookup on its side at intent invocation time fairly easily.

Appreciate your thoughts on this @LN ...

Hello Yann,

I didn't find a way to directly invoke a specific form using for example the jrFormId. But I did a workaround this.

I used a FormContentResolver to get the list of forms from the ODK FormProvider containing the data of registered forms(ID, jrFormId, Date) and then I mapped the forms IDs based on the jrFormId.
Whenever my app starts I match the jrFormId that I have with the one comming form the ODK FormProvider and get the IDs.
So that whenever I chose an Form in my app, its already linked to an ID.

You can load a Cursor with getContentResolver().query(URI, null, null, null, null);
where the URI is content://org.odk.collect.android.provider.odk.forms/forms