Skip to content

Passing Metadata When Launching a Survey From Another App

mnipper edited this page Jul 29, 2014 · 1 revision

Metadata, in the form of JSON, can be passed when launching a survey from another app. This allows a lot of flexibility in terms of what type of info can be passed to a survey when it is launched. You can launch a survey with metadata as follows (assuming instrumentId is a corresponding instrumentId, and metadataJSON is the JSON of the metadata you would like to send):

public final static String EXTRA_PARTICIPANT_METADATA = "org.adaptlab.chpir.android.survey.metadata";
public static final String START_SURVEY = "org.adaptlab.chpir.android.survey.start_survey";
public static final String START_SURVEY_INSTRUMENT_ID = "org.adaptlab.chpir.android.survey.instrument_id";

Intent i = new Intent();
i.setAction(START_SURVEY);
i.putExtra(START_SURVEY_INSTRUMENT_ID, instrumentId);
i.putExtra(EXTRA_PARTICIPANT_METADATA, metadataJSON);
context.sendBroadcast(i);