Skip to content

Launching CommCare With Session Endpoints

Shubham Goyal edited this page Oct 7, 2021 · 2 revisions

Android applications can launch a particular screen in CommCare using the session endpoint id for that form. This is an alternative workflow for the form entry workflow which builds the session state by looking into the suite.xml file of the app.

Prerequisites

In order to use this API, you'll need

  • An CommCare application installed on CommCare 2.51 and above
  • For an user to be currently logged in CommCare
  • The installed CommCare app to define a session endpoint for the screen that we want to launch.

Intent Details

**Action: ** org.commcare.dalvik.action.CommCareSession

**Extras: **

  1. ccodk_session_endpoint_id : Id of the session endpoint corresponding to the screen we want to launch
  2. ccodk_session_endpoint_arguments_bundle or ccodk_session_endpoint_arguments_list : Argument bundle or list that can be passed on to the session endpoint.

Example

Suppose your CommCare app defines an endpoint in the suite.xml as -

<endpoint id="visit_form">
    <argument id="case_id"/>
    <stack>
      <push>
        <command value="'m1-f0'"/>
        <datum id="case_id" value="$case_id"/>
      </push>
    </stack>
  </endpoint>

You can launch this endpoint as -

val intent = Intent("org.commcare.dalvik.action.CommCareSession")
intent.putExtra("ccodk_session_endpoint_id","visit_form")

// Add arguments as a bundle, we can also pass in a list instead
val argsAsBundle = Bundle()
argsAsBundle.putString("case_id", "b319e951-03f1-4172-b662-4fb3964a0be7")
intent.putExtra("ccodk_session_endpoint_arguments_bundle", argsAsBundle)
startActivity(intent);