public final class Survey extends ServiceConnector implements ISurvey
ServiceConnector.InternalServiceConnection
ACTION_BIND_V2, SERVICES_PACKAGE
Modifier and Type | Method and Description |
---|---|
void |
abort()
Abort the current survey.
|
static Survey |
getInstance(android.content.Context context)
Return a global instance of Survey, which is the default implementation of
ISurvey , and instantiate it if needed. |
protected java.lang.String |
getServiceName()
Must be overrided to provide service class name used for binding.
|
protected void |
onServiceReady(android.os.IBinder service)
Internal callback when service is connected.
|
protected void |
onServiceUnbinded()
Internal callback when service is disconnected.
|
void |
registerSurveyDoneListener(ISurveyDoneListener listener)
Register a new listener to receive survey results.
|
SurveyRequest |
start(SurveyInputData inputData)
Prompt user to answer the survey.
|
void |
unregisterSurveyDoneListener(ISurveyDoneListener listener)
Unregister an existing survey listener.
|
connect, connectSync, disconnect, ensureServiceIsReady, getBindIntent, getContext, isConnected
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
connect, disconnect, isConnected
public static Survey getInstance(android.content.Context context)
ISurvey
, and instantiate it if needed.
Be aware that only one instance will be created for the whole application, so the associated
context should not be a component which could be destroyed at some point, ie. an Activity.
Passing the Application
to this method is preferred over other context types.
context
- A valid context to initialize the instance.public SurveyRequest start(SurveyInputData inputData) throws IngenicoException
Example:
ISurvey
survey = Survey.getInstance(context); // First register to surveyDone to show up survey result survey.registerSurveyDoneListener(surveyListener); // Prepare Survey input dataSurveyInputData
inputData =SurveyInputData
.builder() .setMessage("") .setSurveySettings(SurveySettings
.builder() .setSurveyFormat(SurveyFormat
.SURVEY_FORMAT_STAR) .setRatingMaxValue(5) .build()) .build(); // Start the SurveySurveyRequest
request = survey.start(inputData); // Check if request has been accepted if (request.isSurveyAccepted()) { // Ok, the Survey is being processed }
start
in interface ISurvey
IngenicoException
- when a failure occurs while starting a surveypublic void abort() throws IngenicoException
Example:
survey.abort();
abort
in interface ISurvey
IngenicoException
- when a failure occurs while aborting a surveyprotected java.lang.String getServiceName()
ServiceConnector
getServiceName
in class ServiceConnector
public void registerSurveyDoneListener(ISurveyDoneListener listener)
ISurvey
registerSurveyDoneListener
in interface ISurvey
public void unregisterSurveyDoneListener(ISurveyDoneListener listener)
ISurvey
unregisterSurveyDoneListener
in interface ISurvey
protected void onServiceReady(android.os.IBinder service)
ServiceConnector
onServiceReady
in class ServiceConnector
protected void onServiceUnbinded()
ServiceConnector
onServiceUnbinded
in class ServiceConnector