ResearchDroid: An Android Forms and Consent Library

Tap the Power of Smartphones for your Research

Overview

ResearchDroid is a port of Apple’s ResearchKit forthe Android platform. It is actually an android library developed for automating survey forms and information consent building process. The initial launch of ResearchDroid was announced on Nov 9, 2015 at the mHealth conference. ResearchDroid is highly useful in developing health apps, for getting patient consent, and conducting surveys (whether it is demographic or any other survey). To demonstrate the full capabilities of ResearchDroid library, we launched a step-count study in February 2016 on both Android and iOS platforms that leverages ResearchKit features to quickly build a study app –America Walks Study. The app leverages mobile phone’s step count sensor technology to automatically determine participants’ daily walking activity, thus being the first research study to measure such activity using mobile phones, instead of self reported surveys, pedometers or tracking devices.

Features Of ResearchDroid

Create informed Consent Using Json File

Create Consent Pages

Swipeable Views

Indicator to show progress of consent

Create Surveys Forms Using Json File

Creating Form Fields

Validating Form Fields

Wizard form (page by page)

Create signature field for getting user’s consent or any other doc signed

UI:

Material Design UI

ResearchKit like UI

Override style as per own specifications

Getting Started

ResearchDroid acts as a machinery in which we feed specific structured json files and in return we get either the consent pages or survey form wizard. You as a developer do not need to create separate pages for each new informed consent heading or the newly added survey form question/questions.

Adding Dependency

In order to use researchdroid library and start exploring its features, you have to first get researchdroid.aar file. Contact us and we will send you the researchdroid.aar file. Store the file on your pc and, proceed as follows:

Add the researchdroid.aar (compiled AAR file) to your project:

Click File > New Module.

Click Import .JAR/.AAR Package then click Next.

Enter the location of the AAR or JAR file then click Finish.

Make sure the library is listed at the top of your settings.gradle file, as shown here for a library named “my-library-module”:

include ':app',':researchdroid'

Open the app module’s build.gradle file and add a new line to the dependencies block as shown in the following snippet:

dependencies {
compile project(":researchdroid")}

In addition, add the following dependencies also to the app module’s build.gradle file inside dependencies block as shown below:

Note: We use the method startActivityForResult() instead of simple startActivity(). The reason being that when user is done with the subsequent activity and returns, the system calls your calling activity’s onActivityResult() method. This means that we can know whether user has cancelled the activity midway or carried on all the way. This method includes three arguments:

When the ConsentActivity() is called, it fetches the json string from the intent object, reconverts it into jsonObject, iterates through this JsonObject, fetches the JsonArray with key “screens”. Each entry in JsonArray gets converted into the informed consent page/screen. An informed consent page has three main parts:

Page Title

Short Description

Long Description

Note: Long description is by default hidden from page and gets visible only after pressing theLearn more link.

Each JsonArray entry with key “screens” itself contains a JsonArray with key “elements”. This JsonArray has three JsonObjects for each of the three parts of screen.

After ResearchDroid’s ConsentActivity finishes, it returns and we get the response in the calling activity’s onActivityResult() method, and we can handle the cases accordingly. Below is the code snippet:

In addition to the above screens/pages, one more page called review gets created which summarises all information in a single place. This also contains two buttons for Agree/ Disagree for consent. If user clicks Agree, the activity returns RESULT_OK status. On clicking Disagree, activity returns RESULT_CANCELED status with return parameter Constants.RESULT_DISAGREE.

Creating the Survey Form Fields

After the user agrees or gives consent, you can either navigate them to consent confirmation, where user enters their basic details like first name, last name and email id. After this, user is required to draw/write their signature on the screen, or user is directly taken to survey forms. In either of the cases, we must call ResearchDroid’s JsonFormActivity. Following are the various fields/widgets which we can create with JsonFromActivity:

Each field is created by passing a JsonObject. This JsonObject contains information about the display type of the field, label text, validation (is required) etc. Below is the format of JsonObject to be used for generating single form field.

This depicts whether to show the question label or not. It takes Boolean value e.g true.

name

Name of the question field. This is not displayed. It can be empty.

display_type

This is important and required. It tells which field will be created out of this object e.g: if we set display_type : checkbox, a checkbox field will be created. Similarly radio for radio buttons, dropdown for Dropdown items, email for Email field, password for Password field, text for simple Input text, integer for Numerical fields and signature for Signature/Drawing field.

￼￼is_required

This is the validation key. For required fields, is_required is set to true.

id

This is the unique id for each question item.

options

For input type fields, this field can be either empty or absent and is only important for multi-value questions like checkbox, radio buttons, and dropdown. This is a JsonArray of JsonObjects. Each JsonObject is a single entry/option in the field which contains the following entries. Each JsonObject has following entries,

display_name : Label of the option

value: Corresponding value of that option

Is_expected_value : If this is set to true, it means that user has to anyhow select this value. This is useful in checking eligibility criteria

Id : Inique id of the option

order : Order of display of the item

The above shown JsonObject would create a single question in the wizard. Let’s see the full json file to be passed to JsonFormActivity and the code snippet and how it is passed.

With the above code snippet and json file, survey form of two pages with one question each will be created. The validation of each field is done by the library itself on clicking ‘Next’ button at the bottom of the page. When the user finishes filling information in the form and clicks ‘Submit’ button at the last page, the activity finishes with RESULT_OK status and control reaches the onActivityResult() method of calling activity along with the filled information in the form of key value pair where key is the id of the question and value is the entered value. Below is the code snippet for this