use of android.app.NotificationManager in project acra by ACRA.
the class ReportExecutor method createNotification.
/**
* Creates a status bar notification.
*
* The action triggered when the notification is selected is to start the
* {@link CrashReportDialog} Activity.
*
* @param reportFile Report file to send.
*/
private void createNotification(@NonNull File reportFile, @NonNull ReportBuilder reportBuilder) {
final NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
// Default notification icon is the warning symbol
final int icon = config.resNotifIcon();
final CharSequence tickerText = context.getText(config.resNotifTickerText());
final long when = System.currentTimeMillis();
if (ACRA.DEV_LOGGING)
ACRA.log.d(LOG_TAG, "Creating Notification for " + reportFile);
final Intent crashReportDialogIntent = createCrashReportDialogIntent(reportFile, reportBuilder);
final PendingIntent contentIntent = PendingIntent.getActivity(context, mNotificationCounter++, crashReportDialogIntent, PendingIntent.FLAG_UPDATE_CURRENT);
final CharSequence contentTitle = context.getText(config.resNotifTitle());
final CharSequence contentText = context.getText(config.resNotifText());
final NotificationCompat.Builder builder = new NotificationCompat.Builder(context);
final Notification notification = builder.setSmallIcon(icon).setTicker(tickerText).setWhen(when).setAutoCancel(true).setContentTitle(contentTitle).setContentText(contentText).setContentIntent(contentIntent).build();
notification.flags |= Notification.FLAG_AUTO_CANCEL;
// The deleteIntent is invoked when the user swipes away the Notification.
// In this case we invoke the CrashReportDialog with EXTRA_FORCE_CANCEL==true
// which will cause BaseCrashReportDialog to clear the crash report and finish itself.
final Intent deleteIntent = createCrashReportDialogIntent(reportFile, reportBuilder);
deleteIntent.putExtra(ACRAConstants.EXTRA_FORCE_CANCEL, true);
notification.deleteIntent = PendingIntent.getActivity(context, -1, deleteIntent, 0);
// Send new notification
notificationManager.notify(ACRAConstants.NOTIF_CRASH_ID, notification);
}
use of android.app.NotificationManager in project AntennaPod by AntennaPod.
the class GpodnetSyncService method updateErrorNotification.
private void updateErrorNotification(GpodnetServiceException exception) {
Log.d(TAG, "Posting error notification");
GpodnetPreferences.setLastSyncAttempt(false, System.currentTimeMillis());
final String title;
final String description;
final int id;
if (exception instanceof GpodnetServiceAuthenticationException) {
title = getString(R.string.gpodnetsync_auth_error_title);
description = getString(R.string.gpodnetsync_auth_error_descr);
id = R.id.notification_gpodnet_sync_autherror;
} else {
if (UserPreferences.gpodnetNotificationsEnabled()) {
title = getString(R.string.gpodnetsync_error_title);
description = getString(R.string.gpodnetsync_error_descr) + exception.getMessage();
id = R.id.notification_gpodnet_sync_error;
} else {
return;
}
}
PendingIntent activityIntent = ClientConfig.gpodnetCallbacks.getGpodnetSyncServiceErrorNotificationPendingIntent(this);
Notification notification = new NotificationCompat.Builder(this).setContentTitle(title).setContentText(description).setContentIntent(activityIntent).setSmallIcon(R.drawable.stat_notify_sync_error).setAutoCancel(true).setVisibility(NotificationCompat.VISIBILITY_PUBLIC).build();
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
nm.notify(id, notification);
}
use of android.app.NotificationManager in project AntennaPod by AntennaPod.
the class GpodnetSyncService method clearErrorNotifications.
private void clearErrorNotifications() {
NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
nm.cancel(R.id.notification_gpodnet_sync_error);
nm.cancel(R.id.notification_gpodnet_sync_autherror);
}
use of android.app.NotificationManager in project AntennaPod by AntennaPod.
the class FlattrClickWorker method postFlattrFailedNotification.
private void postFlattrFailedNotification() {
int failed = countFailed.get();
if (failed == 0) {
return;
}
PendingIntent contentIntent = ClientConfig.flattrCallbacks.getFlattrFailedNotificationContentIntent(context);
String title;
String subtext;
if (failed == 1) {
title = context.getString(R.string.flattrd_failed_label);
String exceptionMsg = (exception.getMessage() != null) ? exception.getMessage() : "";
subtext = context.getString(R.string.flattr_click_failure, extraFlattrThing.getTitle()) + "\n" + exceptionMsg;
} else {
title = context.getString(R.string.flattrd_label);
subtext = context.getString(R.string.flattr_click_success_count, countSuccess.get()) + "\n" + context.getString(R.string.flattr_click_failure_count, failed);
}
Notification notification = new NotificationCompat.Builder(context).setStyle(new NotificationCompat.BigTextStyle().bigText(subtext)).setContentIntent(contentIntent).setContentTitle(title).setTicker(title).setSmallIcon(R.drawable.stat_notify_sync_error).setOngoing(false).setAutoCancel(true).build();
((NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE)).notify(NOTIFICATION_ID, notification);
}
use of android.app.NotificationManager in project AntennaPod by AntennaPod.
the class FlattrClickWorker method postNoTokenNotification.
private void postNoTokenNotification() {
PendingIntent contentIntent = PendingIntent.getActivity(context, 0, ClientConfig.flattrCallbacks.getFlattrAuthenticationActivityIntent(context), 0);
Notification notification = new NotificationCompat.Builder(context).setStyle(new NotificationCompat.BigTextStyle().bigText(context.getString(R.string.no_flattr_token_notification_msg))).setContentIntent(contentIntent).setContentTitle(context.getString(R.string.no_flattr_token_title)).setTicker(context.getString(R.string.no_flattr_token_title)).setSmallIcon(R.drawable.stat_notify_sync_error).setOngoing(false).setAutoCancel(true).build();
((NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE)).notify(NOTIFICATION_ID, notification);
}
Aggregations