Search in sources :

Example 41 with NotificationManager

use of android.app.NotificationManager in project fresco by facebook.

the class ImagePipelineNotificationFragment method displayNotification.

private void displayNotification(@Nullable Bitmap bitmap) {
    final NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(getContext()).setSmallIcon(R.drawable.ic_done).setLargeIcon(bitmap).setContentTitle(getString(R.string.imagepipeline_notification_content_title)).setContentText(getString(R.string.imagepipeline_notification_content_text));
    final NotificationManager notificationManager = (NotificationManager) getContext().getSystemService(Context.NOTIFICATION_SERVICE);
    notificationManager.notify(NOTIFICATION_ID, notificationBuilder.build());
}
Also used : NotificationManager(android.app.NotificationManager) NotificationCompat(android.support.v4.app.NotificationCompat)

Example 42 with NotificationManager

use of android.app.NotificationManager in project quickstart-android by firebase.

the class MyFirebaseMessagingService method sendNotification.

// [END receive_message]
/**
     * Create and show a simple notification containing the received FCM message.
     *
     * @param messageBody FCM message body received.
     */
private void sendNotification(String messageBody) {
    Intent intent = new Intent(this, MainActivity.class);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, /* Request code */
    intent, PendingIntent.FLAG_ONE_SHOT);
    Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this).setSmallIcon(R.drawable.ic_stat_ic_notification).setContentTitle("FCM Message").setContentText(messageBody).setAutoCancel(true).setSound(defaultSoundUri).setContentIntent(pendingIntent);
    NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    notificationManager.notify(0, /* ID of notification */
    notificationBuilder.build());
}
Also used : NotificationManager(android.app.NotificationManager) NotificationCompat(android.support.v4.app.NotificationCompat) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) PendingIntent(android.app.PendingIntent) Uri(android.net.Uri)

Example 43 with NotificationManager

use of android.app.NotificationManager in project quickstart-android by firebase.

the class MyBaseTaskService method dismissProgressNotification.

/**
     * Dismiss the progress notification.
     */
protected void dismissProgressNotification() {
    NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    manager.cancel(PROGRESS_NOTIFICATION_ID);
}
Also used : NotificationManager(android.app.NotificationManager)

Example 44 with NotificationManager

use of android.app.NotificationManager in project quickstart-android by firebase.

the class MyBaseTaskService method showProgressNotification.

/**
     * Show notification with a progress bar.
     */
protected void showProgressNotification(String caption, long completedUnits, long totalUnits) {
    int percentComplete = 0;
    if (totalUnits > 0) {
        percentComplete = (int) (100 * completedUnits / totalUnits);
    }
    NotificationCompat.Builder builder = new NotificationCompat.Builder(this).setSmallIcon(R.drawable.ic_file_upload_white_24dp).setContentTitle(getString(R.string.app_name)).setContentText(caption).setProgress(100, percentComplete, false).setOngoing(true).setAutoCancel(false);
    NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    manager.notify(PROGRESS_NOTIFICATION_ID, builder.build());
}
Also used : NotificationManager(android.app.NotificationManager) NotificationCompat(android.support.v4.app.NotificationCompat)

Example 45 with NotificationManager

use of android.app.NotificationManager in project FBReaderJ by geometer.

the class NotificationUtil method drop.

public static void drop(Context context, int id) {
    final NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
    notificationManager.cancel(id);
}
Also used : NotificationManager(android.app.NotificationManager)

Aggregations

NotificationManager (android.app.NotificationManager)407 Intent (android.content.Intent)206 PendingIntent (android.app.PendingIntent)200 Notification (android.app.Notification)153 NotificationCompat (android.support.v4.app.NotificationCompat)116 Context (android.content.Context)31 Uri (android.net.Uri)26 Bitmap (android.graphics.Bitmap)24 Resources (android.content.res.Resources)22 TaskStackBuilder (android.support.v4.app.TaskStackBuilder)20 Bundle (android.os.Bundle)19 TaskStackBuilder (android.app.TaskStackBuilder)15 StatusBarNotification (android.service.notification.StatusBarNotification)15 Random (java.util.Random)15 SharedPreferences (android.content.SharedPreferences)13 BitmapFactory (android.graphics.BitmapFactory)13 IntentFilter (android.content.IntentFilter)12 ComponentName (android.content.ComponentName)10 ArrayList (java.util.ArrayList)9 Date (java.util.Date)9