Example usage for android.app Notification DEFAULT_ALL

List of usage examples for android.app Notification DEFAULT_ALL

Introduction

In this page you can find the example usage for android.app Notification DEFAULT_ALL.

Prototype

int DEFAULT_ALL

To view the source code for android.app Notification DEFAULT_ALL.

Click Source Link

Document

Use all default values (where applicable).

Usage

From source file:com.farsunset.ichat.example.receiver.CIMPushManagerReceiver.java

private void showNotify(Context context, Message msg) {

    this.notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
    String title = "?";

    PendingIntent contentIntent = PendingIntent.getActivity(context, 1,
            new Intent(context, SystemMessageActivity.class), PendingIntent.FLAG_UPDATE_CURRENT);
    final NotificationCompat.Builder builder = new NotificationCompat.Builder(context);
    builder.setAutoCancel(true);//from   ww w  .  j a va 2  s.c om
    builder.setDefaults(Notification.DEFAULT_ALL);
    builder.setWhen(msg.getTimestamp());
    builder.setSmallIcon(R.drawable.icon);
    builder.setTicker(title);
    builder.setContentTitle(title);
    builder.setContentText(msg.getContent());
    builder.setDefaults(Notification.DEFAULT_LIGHTS);
    builder.setContentIntent(contentIntent);
    final Notification notification = builder.build();

    notificationManager.notify(R.drawable.icon, notification);

}

From source file:es.usc.citius.servando.calendula.activities.PickupNotification.java

/**
 * Shows the notification, or updates a previously shown notification of
 * this type, with the given parameters.
 * <p/>//from w w w. j a va2 s  . co  m
 * TODO: Customize this method's arguments to present relevant content in
 * the notification.
 * <p/>
 * TODO: Customize the contents of this method to tweak the behavior and
 * presentation of message notifications. Make
 * sure to follow the
 * <a href="https://developer.android.com/design/patterns/notifications.html">
 * Notification design guidelines</a> when doing so.
 *
 * @see #cancel(android.content.Context)
 */
public static void notify(final Context context, final String title, final String description, Intent intent) {

    final Resources res = context.getResources();

    // if notifications are disabled, exit
    // boolean notifications = PreferenceManager.getDefaultSharedPreferences(context).getBoolean("alarm_notifications", true);
    //        if (!notifications) {
    //            return;
    //        }

    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
    String delayMinutesStr = prefs.getString("alarm_repeat_frequency", "15");

    // This image is used as the notification's large icon (thumbnail).
    final Bitmap picture = BitmapFactory.decodeResource(res, R.drawable.ic_event_available_black_48dp);
    //final Bitmap largeIcon = BitmapFactory.decodeResource(res, R.drawable.ic_pill_48dp);

    NotificationCompat.InboxStyle style = new NotificationCompat.InboxStyle();
    style.setBigContentTitle(description);
    //style.setSummaryText("Notification Summary");

    final String ticker = title;
    final String text = title;

    PendingIntent defaultIntent = PendingIntent.getActivity(context, 0, intent,
            PendingIntent.FLAG_CANCEL_CURRENT);

    final NotificationCompat.Builder builder = new NotificationCompat.Builder(context)

            // Set appropriate defaults for the notification light, sound,
            // and vibration.
            .setDefaults(Notification.DEFAULT_ALL).setSmallIcon(R.drawable.ic_event_available_white_48dp)
            .setLargeIcon(picture).setContentTitle(title).setContentText(description).setAutoCancel(true)
            .setPriority(NotificationCompat.PRIORITY_DEFAULT).setLargeIcon(picture).setTicker(ticker)
            .setContentIntent(defaultIntent).setStyle(style).setPriority(Notification.PRIORITY_DEFAULT)
            .setVibrate(new long[] { 1000, 200, 500, 200, 100, 200, 1000 })
            //.setSound(ringtoneUri != null ? ringtoneUri : Settings.System.DEFAULT_NOTIFICATION_URI)
            .setAutoCancel(true);

    Notification n = builder.build();
    n.defaults = 0;
    n.ledARGB = 0x00ffa500;
    n.ledOnMS = 1000;
    n.ledOffMS = 2000;
    notify(context, n);
}

From source file:com.commonsware.android.antidoze.ScheduledService.java

private void foregroundify() {
    NotificationCompat.Builder b = new NotificationCompat.Builder(this);
    Intent iActivity = new Intent(this, EventDemoActivity.class);
    PendingIntent piActivity = PendingIntent.getActivity(this, 0, iActivity, 0);
    Intent iReceiver = new Intent(this, StopReceiver.class);
    PendingIntent piReceiver = PendingIntent.getBroadcast(this, 0, iReceiver, 0);

    b.setAutoCancel(true).setDefaults(Notification.DEFAULT_ALL).setContentTitle(getString(R.string.app_name))
            .setContentIntent(piActivity).setSmallIcon(R.drawable.ic_launcher)
            .setTicker(getString(R.string.app_name))
            .addAction(R.drawable.ic_stop_white_24dp, getString(R.string.notif_stop), piReceiver);

    startForeground(NOTIFY_ID, b.build());
}

From source file:com.app.encontreibvrr.service.MyFirebaseMessagingService.java

/**
 * Create and show a simple notification containing the received FCM message.
 *
 * @param messageBody FCM message body received.
 *//*from  w  ww  .j a v a  2  s .c om*/
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);
    Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
            .setSmallIcon(R.mipmap.ic_launcher).setPriority(Notification.PRIORITY_MAX)
            .setDefaults(Notification.DEFAULT_ALL).setVisibility(Notification.VISIBILITY_PUBLIC)
            .setContentTitle("Encontrei BV RR").setContentText(messageBody).setAutoCancel(true)
            .setSound(defaultSoundUri).setContentIntent(pendingIntent);

    NotificationManager notificationManager = (NotificationManager) getSystemService(
            Context.NOTIFICATION_SERVICE);

    notificationManager.notify(0 /* ID of notification */, notificationBuilder.build());
}

From source file:org.svij.taskwarriorapp.services.NotificationService.java

public int onStartCommand(Intent intent, int flags, int startId) {

    TaskDatabase data = new TaskDatabase(getApplicationContext());
    ArrayList<String> tasks = data.getDueTasks();
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext());

    if (prefs.getBoolean("notifications_due_task", true)) {

        if (tasks.size() > 0) {
            NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
                    .setSmallIcon(R.drawable.ic_launcher)
                    .setContentTitle(tasks.size() + getResources().getString(R.string.notification_title))
                    .setContentText(// w ww  . j  a v  a2s. co  m
                            tasks.size() + getResources().getString(R.string.notification_content_text));
            builder.setAutoCancel(true);

            String alarms = prefs.getString("notifications_due_task_ringtone", "default ringtone");
            Uri uri = Uri.parse(alarms);

            builder.setSound(uri);

            if (prefs.getBoolean("notifications_due_task_vibrate", true)) {
                builder.setDefaults(Notification.DEFAULT_ALL);
            } else {
                builder.setDefaults(Notification.DEFAULT_SOUND);
            }

            Intent resultIntent = new Intent(this, TasksActivity.class);
            TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
            stackBuilder.addParentStack(TasksActivity.class);
            stackBuilder.addNextIntent(resultIntent);

            PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0,
                    PendingIntent.FLAG_UPDATE_CURRENT);

            builder.setContentIntent(resultPendingIntent);

            NotificationManager notificationManager = (NotificationManager) getSystemService(
                    Context.NOTIFICATION_SERVICE);
            notificationManager.notify(0, builder.build());
        }
    }

    return super.onStartCommand(intent, flags, startId);
}

From source file:com.commonsware.android.foredown.Downloader.java

private void raiseNotification(Intent inbound, File output, Exception e) {
    NotificationCompat.Builder b = new NotificationCompat.Builder(this);

    b.setAutoCancel(true).setDefaults(Notification.DEFAULT_ALL).setWhen(System.currentTimeMillis());

    if (e == null) {
        b.setContentTitle(getString(R.string.download_complete)).setContentText(getString(R.string.fun))
                .setSmallIcon(android.R.drawable.stat_sys_download_done)
                .setTicker(getString(R.string.download_complete));

        Intent outbound = new Intent(Intent.ACTION_VIEW);

        outbound.setDataAndType(Uri.fromFile(output), inbound.getType());

        b.setContentIntent(PendingIntent.getActivity(this, 0, outbound, 0));
    } else {/*from   w  ww  . java2 s.c  o  m*/
        b.setContentTitle(getString(R.string.exception)).setContentText(e.getMessage())
                .setSmallIcon(android.R.drawable.stat_notify_error).setTicker(getString(R.string.exception));
    }

    NotificationManager mgr = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);

    mgr.notify(NOTIFY_ID, b.build());
}

From source file:com.nkc.education.service.NotificationHelper.java

/**
 * Basic Text Notification for Task Butler, using NotificationCompat
 *
 * @param context/* w  w w  .j  av a  2 s . c o  m*/
        
 */
public void sendBasicNotification(Context context, Task task) {
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
    boolean vibrate = prefs.getBoolean(AppConfig.VIBRATE_ON_ALARM, true);
    int alarmInterval;
    int alarmUnits;

    if (task.hasFinalDateDue()) {
        alarmInterval = Integer.parseInt(prefs.getString(AppConfig.ALARM_TIME, AppConfig.DEFAULT_ALARM_TIME));
        alarmUnits = Calendar.MINUTE;
    } else {
        alarmInterval = Integer
                .parseInt(prefs.getString(AppConfig.REMINDER_TIME, AppConfig.DEFAULT_REMINDER_TIME));
        alarmUnits = Calendar.HOUR_OF_DAY;
    }

    Calendar next_reminder = GregorianCalendar.getInstance();
    next_reminder.add(alarmUnits, alarmInterval);

    Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(), R.mipmap.ic_launcher);
    NotificationCompat.Builder builder = new NotificationCompat.Builder(context).setAutoCancel(true)
            .setContentIntent(getPendingIntent(context, task.getID()))
            .setContentInfo(Task.PRIORITY_LABELS[task.getPriority()]).setContentTitle(task.getName())
            .setContentText(task.getDetail())
            .setDefaults(vibrate ? Notification.DEFAULT_ALL
                    : Notification.DEFAULT_SOUND | Notification.DEFAULT_LIGHTS)
            .setSmallIcon(Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB ? R.drawable.ic_exam_name
                    : R.drawable.ic_exam_name)
            .setLargeIcon(bitmap).setTicker(task.getName()).setPriority(Notification.PRIORITY_MAX)
            .setColor(Color.argb(255, 21, 149, 196)).setWhen(System.currentTimeMillis());

    @SuppressWarnings("deprecation")
    Notification notification = builder.getNotification();
    NotificationManager notificationManager = getNotificationManager(context);
    notificationManager.notify(task.getID(), notification);
}

From source file:edu.worcester.cs499summer2012.service.NotificationHelper.java

/**
 * Basic Text Notification for Task Butler, using NotificationCompat
 * @param context //from www .  j  a v a  2  s. c  om
 * @param id id of task, call task.getID() and pass it to this parameter
 */
public void sendBasicNotification(Context context, Task task) {
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
    boolean vibrate = prefs.getBoolean(SettingsActivity.VIBRATE_ON_ALARM, true);
    int alarmInterval;
    int alarmUnits;

    if (task.hasFinalDateDue()) {
        alarmInterval = Integer
                .parseInt(prefs.getString(SettingsActivity.ALARM_TIME, SettingsActivity.DEFAULT_ALARM_TIME));
        alarmUnits = Calendar.MINUTE;
    } else {
        alarmInterval = Integer.parseInt(
                prefs.getString(SettingsActivity.REMINDER_TIME, SettingsActivity.DEFAULT_REMINDER_TIME));
        alarmUnits = Calendar.HOUR_OF_DAY;
    }

    Calendar next_reminder = GregorianCalendar.getInstance();
    next_reminder.add(alarmUnits, alarmInterval);

    NotificationCompat.Builder builder = new NotificationCompat.Builder(context).setAutoCancel(true)
            .setContentIntent(getPendingIntent(context, task.getID()))
            .setContentInfo(Task.PRIORITY_LABELS[task.getPriority()]).setContentTitle(task.getName())
            .setContentText(DateFormat.format("'Next reminder at' h:mmaa", next_reminder))
            .setDefaults(vibrate ? Notification.DEFAULT_ALL
                    : Notification.DEFAULT_SOUND | Notification.DEFAULT_LIGHTS)
            .setSmallIcon(Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB ? R.drawable.ic_notification
                    : R.drawable.ic_notification_deprecated)
            .setTicker(task.getName()).setWhen(System.currentTimeMillis());
    @SuppressWarnings("deprecation")
    Notification notification = builder.getNotification();
    NotificationManager notificationManager = getNotificationManager(context);
    notificationManager.notify(task.getID(), notification);
}

From source file:org.kde.kdeconnect.Plugins.PingPlugin.PingPlugin.java

@Override
public boolean onPackageReceived(NetworkPackage np) {

    if (!np.getType().equals(PACKAGE_TYPE_PING)) {
        Log.e("PingPlugin", "Ping plugin should not receive packets other than pings!");
        return false;
    }/* w w  w  .  j  a v a  2 s.com*/

    //Log.e("PingPackageReceiver", "was a ping!");

    TaskStackBuilder stackBuilder = TaskStackBuilder.create(context);
    stackBuilder.addParentStack(MaterialActivity.class);
    stackBuilder.addNextIntent(new Intent(context, MaterialActivity.class));
    PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);

    int id;
    String message;
    if (np.has("message")) {
        message = np.getString("message");
        id = (int) System.currentTimeMillis();
    } else {
        message = "Ping!";
        id = 42; //A unique id to create only one notification
    }

    Notification noti = new NotificationCompat.Builder(context).setContentTitle(device.getName())
            .setContentText(message).setContentIntent(resultPendingIntent).setTicker(message)
            .setSmallIcon(R.drawable.ic_notification).setAutoCancel(true).setDefaults(Notification.DEFAULT_ALL)
            .build();

    NotificationManager notificationManager = (NotificationManager) context
            .getSystemService(Context.NOTIFICATION_SERVICE);
    NotificationHelper.notifyCompat(notificationManager, id, noti);

    return true;

}

From source file:damo.three.ie.prepay.InternetAddonExpireReceiver.java

@Override
public void onReceive(Context context, Intent intent) {

    long millis = intent.getExtras().getLong(InternetUsageRegistry.INTERNET_EXPIRE_TIME);

    boolean alreadyExpired = false;

    if (millis > 0) {
        long now = new DateTime().getMillis();
        if (now > millis) {
            alreadyExpired = true;//  w  ww.  j a  va 2  s. c  o m
        }
    }

    // Clicking on the notification opens the InternetExpirationActivity.
    Intent myIntent = new Intent(context, InternetExpirationActivity.class);
    myIntent.putExtra(InternetUsageRegistry.INTERNET_EXPIRED, alreadyExpired);
    PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, myIntent, PendingIntent.FLAG_ONE_SHOT);

    Bitmap largeIcon = BitmapFactory.decodeResource(context.getResources(), R.drawable.ic_launcher);

    NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context)
            .setSmallIcon(R.drawable.ic_warning).setLargeIcon(largeIcon)
            .setContentTitle(context.getString(alreadyExpired ? R.string.internet_addon_expired_title
                    : R.string.internet_addon_expiring_title))
            .setTicker(context.getString(alreadyExpired ? R.string.internet_addon_expired_title
                    : R.string.internet_addon_expiring_title))
            .setContentText(context.getString(alreadyExpired ? R.string.internet_addon_expired_text
                    : R.string.internet_addon_expiring_text))
            .setAutoCancel(true).setDefaults(Notification.DEFAULT_ALL).setContentIntent(pendingIntent);

    NotificationManager mNotificationManager = (NotificationManager) context
            .getSystemService(Context.NOTIFICATION_SERVICE);

    mNotificationManager.notify(0, mBuilder.build());
}