// TODO: alternatively could use the same app wide if want only one entry in notifications
private void postNotification(Context context, AnswerSet answerSet, String message) {
        int surveyId = answerSet.getDbSurveyId();
        NotificationManager notificationManager = (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
        Intent intent = new Intent(context, SurveyActivity.class);
        intent.putExtra("programId", answerSet.getDbProgramId());
        intent.putExtra("answerSetUUID", answerSet.getUuid());
        intent.setAction("com.sema.notification." + surveyId);
        PendingIntent pIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
        Survey survey = answerSet.getSurvey();
        Program program = survey != null ? survey.getProgram() : null;
        if (survey != null && program != null) {
            String programName = program.getDisplayName();
            Notification n = new NotificationCompat.Builder(context)
                    .setContentTitle(programName)
                    .setContentText(message)
                    .setSmallIcon(R.drawable.ic_launcher)
                    .setContentIntent(pIntent)
                    .setAutoCancel(true)
                    .setSound(Uri.parse("android.resource://" + context.getPackageName() + "/" + R.raw.notification_extended))
                    .build();
            notificationManager.notify(answerSet.getStartAlarmRequestCode(), n); // TODO: alternatively could use the same app wide if want only one entry in notifications
        }
    }
.setSound(Uri.parse("android.resource://" + context.getPackageName() + "/" + R.raw.notification_extended))
.build();
notificationManager.notify(answerSet.getStartAlarmRequestCode(), n); // TODO: alternatively could use the same app wide if want only one entry in notifications
}
}
if (survey != null && program != null) {
String programName = program.getDisplayName();
Notification n = new NotificationCompat.Builder(context)
.setContentTitle(programName)
.setContentText(message)
.setSmallIcon(R.drawable.ic_launcher)
.setContentIntent(pIntent)
.setAutoCancel(true)
.setSound(Uri.parse("android.resource://" + context.getPackageName() + "/" + R.raw.notification_extended))
.build();
notificationManager.notify(answerSet.getStartAlarmRequestCode(), n); // TODO: alternatively could use the same app wide if want only one entry in notifications
}
}
private void postNotification(Context context, AnswerSet answerSet, String message) {
int surveyId = answerSet.getDbSurveyId();
NotificationManager notificationManager = (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
Intent intent = new Intent(context, SurveyActivity.class);
intent.putExtra("programId", answerSet.getDbProgramId());
intent.putExtra("answerSetUUID", answerSet.getUuid());
intent.setAction("com.sema.notification." + surveyId);
PendingIntent pIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
Survey survey = answerSet.getSurvey();
Program program = survey != null ? survey.getProgram() : null;
if (survey != null && program != null) {
String programName = program.getDisplayName();
Notification n = new NotificationCompat.Builder(context)
.setContentTitle(programName)
.setContentText(message)
.setSmallIcon(R.drawable.ic_launcher)
.setContentIntent(pIntent)
.setAutoCancel(true)
.setSound(Uri.parse("android.resource://" + context.getPackageName() + "/" + R.raw.notification_extended))
.build();
notificationManager.notify(answerSet.getStartAlarmRequestCode(), n); // TODO: alternatively could use the same app wide if want only one entry in notifications
}
}