Coder Social home page Coder Social logo

survata-android-public-sdk's Introduction

Survata Android SDK

Requirements

  • 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)

How to create aar and upload to jcenter

  1. Register for an account on bintray.com

  2. 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 in build.gradle
         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
  1. Sync bintray user repository to jcenter

    • You now have your own Maven Repository on Bintray which is ready to be uploaded to the library.

    ScreenShot

    • Nothing to do but click Send

    ScreenShot

    • 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.

    ScreenShot

Usage

Please check out demo app for a real-life demo.

Step 1

Add dependencies in build.gradle. 1.0.16 is the latest version.

        dependencies {
            compile 'com.survata.android:Survata:1.0.16'
        }

Step 2

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" />

Step 3

Define Survey

    private Survey mSurvey;
    
    private Button mSurveyButton;
    
    ...
    

Step 4

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);
                            }
                        }
                    });
        }

IMPORTANT NOTE

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";

Step 5

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);
                        }
                    }
                });
            }

survata-android-public-sdk's People

Contributors

theresagao avatar anntisa avatar scourtain avatar audioarchitect avatar jameswwarner avatar wangdaliu avatar

Watchers

Chris Wagner avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.