The minimum Android version required is 21
. Also, the compile SDK version version for android is 34
(But you should generally compile with the latest version)
The SDK is available on the central Maven repository. Add it in your root settings.gradle.
dependencyResolutionManagement {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
Add a reference to the latest version of QuestionPro SDK in your app's build.gradle.
dependencies {
implementation 'com.github.surveyanalyticscorp:android-cx:labs_2.0'
}
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
Add the api key obtained from QuestionPro portal:
<meta-data android:name="cx_manifest_api_key" android:value="your api key here"/>
<activity android:name="com.questionpro.cxlib.interaction.InteractionActivity"
android:theme="@android:style/Theme.Translucent.NoTitleBar"
android:configChanges="keyboardHidden"
android:windowSoftInputMode="adjustPan"/>
You have to initialize the SDK in the Main Activity, For example:
TouchPoint touchPoint=new TouchPoint.Builder(DataCenter.US).build();
QuestionProCX.getInstance().init(this, touchPoint, new IQuestionProInitCallback() {
@Override
public void onSuccess(String message) {
Log.d(TAG, "onSuccess: "+message);
}
@Override
public void onFailed(String error) {
Log.d(TAG, "onFailed: "+error);
}
@Override
public void getSurveyUrl(String url) {
Log.d(TAG, "Survey url: "+url);
}
});
(TouchPoint constructor requires Data Center as a default parameter)
You have to reset the QuestionPro's intercept SDK just before your app getting closed. Generraly,
you can do it in the onDestroy() method of your applications main activity.
Please note that, onDestroy() is not guaranteed to execute due to system kills, app crashes, or explicit process termination.
QuestionProCX.getInstance().clearSession();