SurveySparrow’s Mobile SDK lets you embed your surveys in your native Android apps. With today's mobile-driven population, gauging your customers for feedback from your mobile application is a surefire way to increase survey response rates, and gain the insights you need.

For instance, let's say you own an app for movie streaming, and you want to provide a more personalized experience and viewing recommendations to your viewers. To understand your viewers' likes and dislikes, you can ask them to rate a movie/documentary after they have finished watching it. By doing so, you can understand each viewer's preferences and interests, which can further help you in providing personalized movie recommendations.

By using SurveySparrow’s Mobile SDK, you can trigger a survey in your app using just a few lines of code, and analyze all the results in SurveySparrow's reporting module.

Let’s see how it works:

  1. Create a movie review survey and include a Rating question. Navigate to Share.
  2. Select Mobile SDK from the list of sharing channels.
  3. Copy the token.

4. Now, let’s move on to the coding part:

Add SurveySparrow’s Android SDK to your app
Add the following line of code to the dependencies section of the app modules build.gradle file.

dependencies { 

implementation 'com.surveysparrow:ss-android-sdk:0.1.0'

}

Add permissions

The SDK uses the internet to fetch surveys and submit responses to SurveySparrow. Add internet permissions in your AndroidManifest.xml file.

<uses-permission android:name="android.permission.INTERNET" /> 
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

Create and show a survey(using Kotlin)

You can trigger a survey anywhere from your application at any time.

Here’s how:

  1. Create a survey.
val survey = SsSurvey("example.com(your company domain)", "sdk-token")

2. Configure the SurveySparrow object.

val surveySparrow = SurveySparrow(this, survey)

3. Start the movie review survey.

surveySparrow.startSurveyForResult(RATE_MOVIE_REQUEST)

RATE_MOVIE_REQUEST is an integer constant that is passed to identify the request. The ‘startSurveyForResult’ function triggers an inbuilt ‘startActivityResult’ and it can be called multiple times so that the constant can be used to identify the result in the ‘onActivityResult’ handler.

4. Handle survey responses.

override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { 
super.onActivityResult(requestCode, resultCode, data)
if(requestCode == RATE_MOVIE_REQUEST) {
if(resultCode == Activity.RESULT_OK) {
// Get the survey response
val response = SurveySparrow.toJSON(data?.data.toString())
val responseData = response.getJSONArray("response")
val rating = responseData.getJSONObject(0).getInt("answer")

// Show a recommendation page if the user give 4+ rating
if(rating >= 4) {
startActivity(Intent(this,RecommendationsActivity::class.java))
} else {
finish()
}
} else {
Log.v(LOG_TAG, "Review survey not completed!")
}
}
}

This code block will be executed once the survey has been submitted or left incomplete. Once the survey is completed, and the rating given is 4 and above, respondents will be directed to a recommendations page. If the rating given is below 4, respondents will be redirected to the home page of the app.

If a respondent leaves the survey incomplete, a ‘Review survey not completed!’ message will be displayed on the console.

Note: The developer can parse the responses and customize the behavior however they want.

Enhancements

Passing data

To offer more personalization, the movie name can be passed as data from your app to your survey by using Custom Variables.

Here’s how:

  1. Click on the Global Variables icon on the left-sidebar on your survey, and create a variable called ‘movieName’.

2. Use this variable in your Rating question by clicking the dollar sign($) next to the question.

3. Now, use the addCustomParam method in your survey object to share values from your app to the survey.

survey.addCustomParam("movieName", "Sparrow Life")

Styling

You can style your survey to match the theme of your app by using Custom CSS. Paste the following code in the Advanced Editor. This will hide the bottom navigator, progress button, and password warning message in the survey.

.ss_classic_footer_right_content_wrap { 
visibility: hidden;
}
.ss_cl_survey_submit_resp > p {
visibility: hidden;
}
.ss-progress-container--new {
visibility: hidden;
}

You can further customize your survey by removing the SurveySparrow branding and by adding your custom logo.

Other configurations

If you are planning to collect multiple reviews from the same viewer for different movies in your app, you can do so by enabling the ‘Allow multiple submissions per user’ option under Survey Settings(Go to Config > General Settings).

You can find the full code of the Movie App here. For the full SDK documentation, please visit https://github.com/surveysparrow/surveysparrow-android-sdk

Did this answer your question?