Skip to content

Commit

Permalink
v1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
BenL committed Jan 26, 2016
0 parents commit a5ba877
Show file tree
Hide file tree
Showing 35 changed files with 791 additions and 0 deletions.
22 changes: 22 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
The MIT License (MIT)

Copyright (c) 2015 SurveyMonkey

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

75 changes: 75 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
## SurveyMonkey Feedback SDK for Android

The SurveyMonkey Feedback SDK for Android allows app developers to integrate SurveyMonkey surveys and respondent data into their apps. Checkout our [documentation site](http://surveymonkey.github.io/surveymonkey-android-sdk/) for more information.

We strive to fix bugs and add new features as quickly as possible. Please watch our Github repo to stay up to date.

To download the SDK, either clone the SDK
```bash
git clone https://github.com/SurveyMonkey/surveymonkey-android-sdk.git
```
Or download the [latest release](https://github.com/SurveyMonkey/surveymonkey-android-sdk/releases)

### Setting up your SDK Collector

To use the SurveyMonkey Feedback SDK, you must first create a survey on [ SurveyMonkey.com](https://www.surveymonkey.com).

1. Once you have created your SurveyMonkey survey, navigate to the **Collect** tab and select **+ New Collector > SDK** from the menu on the righthand side.
2. Click **Generate** - The code you generate is your **Survey Hash**, you'll use this to point the SDK to your survey in the steps below.
### Integrating with Android Studio

1. From the menu bar, click **File -> New Module -> Import .JAR or .AAR package**
2. Navigate to the **surveymonkeyandroidsdk** directory that is contained in the **surveymonkeyandroidsdk** repo
3. Select the **surveymonkey-android-sdk.aar** file and click Finish
4. In your **AndroidManifest.xml** file, make sure you've included the `<uses-permission android:name="android.permission.INTERNET"/>` permission
5. Make sure your **build.gradle** file has `compile project(':surveymonkey_android_sdk')` under `dependencies {}`

That's it!

###Integrating the SurveyMonkey SDK with your app
For a detailed example, take a look at the **SimpleActivity** sample project in our Github repo


#### Important
The SurveyMonkey Feedback SDK makes use of the `startActivityForResult(Intent, int)` method lifecycle - thus, if you want to consume the respondent data returned by our SDK, you'll need to implement `onActivityResult()` in whichever activity you present surveys from.

The survey respondent data is returned as JSON. To parse it, implement the following in your `onActivityResult()`:
```java
String respondent = intent.getStringExtra("smRespondent");
JSONObject surveyResponse = new JSONObject(respondent);
```

If `resultCode != RESULT_OK` in your `onActivityResult`, an error has occurred. To obtain and parse the error into an SMError object, call:
```java
SMError e = (SMError) intent.getSerializableExtra(SM_ERROR);
```

#### Getting Started
1. `import com.surveymonkey.surveymonkeyandroidsdk.SurveyMonkey;` and (for error handling)
`import com.surveymonkey.surveymonkeyandroidsdk.utils.SMError;`
2. Initialize the SDK like so: `private SurveyMonkey sdkInstance = new SurveyMonkey();`

#### The Intercept Modal
To kick off the SurveyMonkey Feedback SDK Intercept process, call:
```java
sdkInstance.onStart(this, [SAMPLE_APP_NAME], [SAMPLE_REQUEST_CODE], [SAMPLE_SURVEY_HASH]);
```
from your main activity. This will check to see if the user should be prompted to take your survey (i.e. `if (timeSinceLastSurveyPrompt > maxTimeIntervalBetweenSurveyPrompts)`). The copy of the prompts, as well as the time intervals, can be customized, see our docs for more information.

If you are a **Platinum** user and want to include custom variables with each survey response, create a flat JSONObject with your custom variables and use:
```java
sdkInstance.onStart(this, [SAMPLE_APP_NAME], [SAMPLE_REQUEST_CODE], [SAMPLE_SURVEY_HASH], [SAMPLE_CUSTOM_VARIABLES_DICTIONARY]);
```

#### Presenting a Survey to the User
To present a survey for the user to take, call
```java
sdkInstance.startSMFeedbackActivityForResult(this, [SAMPLE_REQUEST_CODE], [SAMPLE_SURVEY_HASH]);
```
Again, if you are a **Platinum** user and want to include custom variables with each survey response, create a flat JSONObject with your custom variables and use:
```java
sdkInstance.startSMFeedbackActivityForResult(this, [SAMPLE_REQUEST_CODE], [SAMPLE_SURVEY_HASH], [SAMPLE_CUSTOM_VARIABLES_DICTIONARY]);
```

####Issues and Bugs
Please submit any issues with the SDK to us via Github issues.
1 change: 1 addition & 0 deletions SimpleSurvey/.idea/.name

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions SimpleSurvey/.idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions SimpleSurvey/.idea/copyright/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions SimpleSurvey/.idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

74 changes: 74 additions & 0 deletions SimpleSurvey/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions SimpleSurvey/.idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions SimpleSurvey/.idea/runConfigurations.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions SimpleSurvey/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions SimpleSurvey/app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.2"

defaultConfig {
applicationId "com.surveymonkey.simplesurvey"
minSdkVersion 9
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile project(':surveymonkey_android_sdk')
}
17 changes: 17 additions & 0 deletions SimpleSurvey/app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /Users/benl/sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.surveymonkey.simplesurvey;

import android.app.Application;
import android.test.ApplicationTestCase;

/**
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
*/
public class ApplicationTest extends ApplicationTestCase<Application> {
public ApplicationTest() {
super(Application.class);
}
}
24 changes: 24 additions & 0 deletions SimpleSurvey/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.surveymonkey.surveymonkeyandroidsdkexample">

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

<application
android:allowBackup="true"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:theme="@style/AppTheme">
<activity
android:name="com.surveymonkey.simplesurvey.SimpleActivity"
android:label="Simple Activity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>

<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>

</application>

</manifest>
Loading

0 comments on commit a5ba877

Please sign in to comment.