- Android 4.0 (API Version 14) and up
- android-support-v4.jar, r23 (Updated in 1.0.5)
- android-support-annotations.jar, r23 (Updated in 1.0.5)
- Volley Library (library-1.0.19.jar)(Updated in 1.0.5)
-
Register for an account on bintray.com
-
Package aar and upload
bintray-release, it provides an easy way to release your Android and other artifacts to bintray.
Refer the steps in README.md.
- modify
publish
closure inbuild.gradle
- modify
publish {
userOrg = ''
groupId = ''
artifactId = ''
publishVersion = ''
desc = ''
website = ''
}
* use the task `bintrayUpload` to publish (make sure you build the project first!):
$ ./gradlew clean build bintrayUpload -PbintrayUser=BINTRAY_USERNAME -PbintrayKey=BINTRAY_KEY -PdryRun=false
-
Sync bintray user repository to jcenter
- You now have your own Maven Repository on Bintray which is ready to be uploaded to the library.
- Nothing to do but click Send
- It is pretty easy to sync your library to jcenter. Just go to the web interface and simply click at "Add to JCenter". Nothing we can do now but wait for 2-3 hours to let bintray team approves our request. Once sync request is approved, you will receive an email informing you the change.
Please check out demo app for a real-life demo.
Add dependencies in build.gradle
. 1.0.16 is the latest version.
dependencies {
compile 'com.survata.android:Survata:1.0.16'
}
Add permissions in AndroidManifest.xml
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
// optional, if you want to send zipcode
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
Define Survey
private Survey mSurvey;
private Button mSurveyButton;
...
Check survey availability. The publisherId property is @NonNull
.
public void checkSurvey() {
Context context = getContext();
SurveyOption option = new SurveyOption(publisherId);
mSurvey = new Survey(option);
mSurvey.create(getActivity(),
new Survey.SurveyAvailabilityListener() {
@Override
public void onSurveyAvailable(Survey.SurveyAvailability surveyAvailability) {
if (surveyAvailability == Survey.SurveyAvailability.AVAILABILITY) {
mSurveyButton.setVisibility(View.VISIBLE);
}
}
});
}
There is a frequency cap on how many surveys we allow one day for a specific IP address. Thus while testing/developing, it might be frustrating to not see surveys appear after a couple of tries. You can bypass this in two ways.
####1. FIRST WAY: Using "testing" property
There is a property called testing which is a boolean that can be set to true. Below is a snippet of the previous code above that includes the testing property. This will bring up real surveys (that might take very long to answer, so look at the second way), but your responses are not recorded.
SurveyOption option = new SurveyOption(publisherId);
option.testing = true;
mSurvey = new Survey(option);
####2. SECOND WAY: Using a default survey with SurveyOption, "preview" property & demo survey preview id
There is a property called preview that allows you to set a default preview Id for a survey (thus, have a specific survey). We have a default short demo survey with just 3 questions at Survata that is perfect for testing that uses the preview id 5fd725139884422e9f1bb28f776c702d. Here's some code as to show you how to integrate it:
SurveyOption option = new SurveyOption(publisherId);
option.preview = "5fd725139884422e9f1bb28f776c702d";
Show survey in WebView. Should called after checkSurvey(); It will return the survey events (COMPLETED, SKIPPED, CANCELED, CREDIT_EARNED, NETWORK_NOT_AVAILABLE, NO_SURVEY_AVAILABLE).
private void showSurvey() {
mSurvey.createSurveyWall(getActivity(), new Survey.SurveyStatusListener() {
@Override
public void onResult(Survey.SurveyEvents surveyEvents) {
if (surveyEvents == Survey.SurveyEvents.COMPLETED) {
mSurveyButton.setVisibility(View.GONE);
}
}
});
}