Download surveys
These are optional implementations when downloading Sense360 surveys.
Callback receiver
The Callback receiver receives and listens to surveys whenever the SDK downloads them. These surveys may be displayed within the application interface (UI) to be consistent with the other survey displayed within the application.
To listen and receive surveys, implement a new public SurveyReceiver
class (which extends BroadcastReceiver
class) in your AndroidManifest.xml
to catch the Intent
that includes the downloaded survey object.
<receiver
android:name=".SurveyReceiver"
android:enabled="false"
android:exported="true">
<intent-filter>
<action android:name="com.sense360.intent.action.SURVEY_DOWNLOAD"/>
</intent-filter>
</receiver>
This is an example of SurveyReceiver.java
import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import com.sense360.android.quinoa.lib.surveys.Sense360Survey;
/**
* This class is responsible for catching {@link com.sense360.android.quinoa.lib.surveys.Sense360Survey} object download.
*/
public class SurveyReceiver extends BroadcastReceiver {
private static final String TAG = "SurveyReceiver";
@Override
public void onReceive(Context context, Intent intent) {
Log.d(TAG, "Sense360Survey received");
Sense360Survey survey = (Sense360Survey) intent.getParcelableExtra("survey");
showSurvey(context, survey);
}
private void showSurvey(Context context, Sense360Survey survey) {
Intent intent = new Intent(context, SurveyActivity.class);
intent.putExtra("survey", survey);
intent.addFlags(FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
}
}
Access method
The Sense360 SDK has getPreviouslyDownloadedSurveys()
public method that returns the last survey the SDK has downloaded, if any. These surveys may be displayed within the application interface (UI) to be consistent with the other survey displayed within the application.
The SDK only downloads one survey at a time, and only one is available on the device. Additionally, you can use the Callback receiver to be automatically notified when a new survey is available.
private void getPreviouslyDownloadedSurveys() {
List<Survey> list = Sense360Testing.getPreviouslyDownloadedSurveys(this);
if (list.size() > 0) {
Sense360Survey survey = list.get(0);
Intent intent = new Intent(this, SurveyActivity.class);
intent.putExtra("survey", survey);
startActivity(intent);
}
}
Survey object table
When downloading a survey, these fields are part of the survey object table:
Field name | Data type | Description | Example |
---|---|---|---|
survey_url | String | The URL for the available survey | https://surveys.give-feedback.co/survey?app_id=com.sense360.example&user_id=53161697-CC0E-4145-9DE4-04D715B603FD&p=1&audit_id=&survey_id=717133ad-e11d-47a6-b319-13049c0bdd72 |
survey_available | Boolean | Whether this survey is still available at the time of downloading it | true |
project_id | String | The project ID associated with the survey | "eae547ec-d93e-43ca-bf9c-553ebcee9ba1 -123" |
survey_title | String | The title for the available survey | Quick survey opportunity! |
survey_description | String | The description for the available survey | Short survey related to the brands you recently visited. |
length_of_interview | Integer | The number of minutes of the interview | 5 |
third_party_user_id | String | The third-party user ID provided by integrating application | "0123456789" |
survey_id | String | The Sense360 assigned unique survey ID | "d0121724-bbd6-4ee2-8c15-64d48748ed82" |