public ApptentiveTaskManager(Context context, ApptentiveHttpClient apptentiveHttpClient, EncryptionKey encryptionKey) {
dbHelper = new ApptentiveDatabaseHelper(context, encryptionKey);
singleThreadExecutor = new ThreadPoolExecutor(1, 1,
30L, TimeUnit.SECONDS,
new LinkedBlockingQueue<Runnable>(),
new ThreadPoolExecutor.CallerRunsPolicy());
singleThreadExecutor.allowCoreThreadTimeOut(true);
payloadSender = new PayloadSender(apptentiveHttpClient, new HttpRequestRetryPolicyDefault() {
@Override
public boolean shouldRetryRequest(int responseCode, int retryAttempt) {
return false;
}
});
payloadSender.setListener(this);
ApptentiveNotificationCenter.defaultCenter()
.addObserver(NOTIFICATION_CONVERSATION_STATE_DID_CHANGE, this)
.addObserver(NOTIFICATION_APP_ENTERED_BACKGROUND, this)
.addObserver(NOTIFICATION_APP_ENTERED_FOREGROUND, this);
}