This app is for testing the ODK Collect app and presenting how to open activities of ODK Collect directly from an external app.
ODK Collect allows us to open several of its activities from another app. You can open a specific form or lists of empty forms, saved forms, finalized forms or sent forms.
Thanks to that you can build your own app that interact with ODK Collect through intents.
If you want to start ODK Collect's activity you need to:
- Create a new intent using an appropriate action.
- Set the type of created intent.
- Start an activity using the intent.
The code should look like below (in this case it's the Form Chooser list):
public void startFormChooserList(View view) {
Intent i = new Intent(Intent.ACTION_VIEW);
i.setType(FORMS_CHOOSER_INTENT_TYPE);
startActivityIfAvailable(i);
}
where
FORMS_CHOOSER_INTENT_TYPE = "vnd.android.cursor.dir/vnd.odk.form";
You can find all the other examples in MainActivity or ListActivity.
On the other side you can also open other apps from ODK Collect, for example in order to read a value - see the ODK Counter.
Apache License, Version 2.0 http://www.apache.org/licenses/LICENSE-2.0.html