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.z3r0byte.magistify.Services.BackgroundService.java

private void unFinishedHomeworkNotification() {
    String lastCheck = configUtil.getString("last_unfinished_homework_check");
    if (lastCheck.equals(""))
        lastCheck = DateUtils.formatDate(DateUtils.addDays(new Date(), -1), "yyyyMMdd");

    Date lastCheckDate = DateUtils.parseDate(lastCheck, "yyyyMMdd");
    Date now = DateUtils.parseDate(DateUtils.formatDate(new Date(), "yyyyMMdd"), "yyyyMMdd");
    Integer hours = configUtil.getInteger("unfinished_homework_hour");
    Integer minutes = configUtil.getInteger("unfinished_homework_minute");
    if (lastCheckDate.before(now)) {
        lastCheckDate = DateUtils.addHours(lastCheckDate, 24 + hours);
        lastCheckDate = DateUtils.addMinutes(lastCheckDate, minutes);
        if (new Date().after(lastCheckDate)) {
            Appointment[] appointments = calendarDB.getUnfinishedAppointments(DateUtils.addDays(now, 1));

            if (appointments.length > 0) {

                NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context);
                mBuilder.setSmallIcon(R.drawable.ic_unfinished_homework);
                mBuilder.setContentTitle("Huiswerk waarschuwing");

                if (appointments.length == 1) {
                    mBuilder.setContentText(appointments[0].description);
                } else {
                    String content = "Je hebt je huiswerk voor de volgende lessen van morgen nog niet afgerond:";
                    for (Appointment appointment : appointments) {
                        String string = appointment.description;
                        if (content.length() > 1) {
                            content = content + "\n" + string;
                        } else {
                            content = string;
                        }/*from  ww  w  . java2 s.com*/
                    }
                    mBuilder.setStyle(new NotificationCompat.BigTextStyle(mBuilder).bigText(content));
                    mBuilder.setContentText(content);
                }
                mBuilder.setAutoCancel(true);
                mBuilder.setVisibility(NotificationCompat.VISIBILITY_PRIVATE);
                mBuilder.setDefaults(Notification.DEFAULT_ALL);
                mBuilder.setLights(Color.RED, 300, 200);

                Intent resultIntent = new Intent(context, HomeworkActivity.class);
                TaskStackBuilder stackBuilder = TaskStackBuilder.create(context);
                stackBuilder.addParentStack(NewGradeActivity.class);
                stackBuilder.addNextIntent(resultIntent);
                PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0,
                        PendingIntent.FLAG_UPDATE_CURRENT);
                mBuilder.setContentIntent(resultPendingIntent);

                NotificationManager mNotificationManager = (NotificationManager) context
                        .getSystemService(Context.NOTIFICATION_SERVICE);
                if (Build.VERSION.SDK_INT >= 26) {
                    String channelId = UNFINISHED_HOMEWORK_NOTIFICATIONCHANNEL_ID;
                    CharSequence channelName = UNFINISHED_HOMEWORK_NOTIFICATIONCHANNEL_ID;
                    int importance = NotificationManager.IMPORTANCE_LOW;
                    NotificationChannel notificationChannel = new NotificationChannel(channelId, channelName,
                            importance);
                    notificationChannel.enableLights(true);
                    notificationChannel.setLightColor(Color.RED);
                    notificationChannel.enableVibration(true);
                    notificationChannel.setImportance(NotificationManager.IMPORTANCE_DEFAULT);
                    notificationChannel.setVibrationPattern(new long[] { 100, 200, 150 });
                    mNotificationManager.createNotificationChannel(notificationChannel);
                    mBuilder.setChannelId(UNFINISHED_HOMEWORK_NOTIFICATIONCHANNEL_ID);
                }
                mNotificationManager.notify(UNFINISHED_HOMEWORK_NOTIFICATION_ID, mBuilder.build());
            }

            configUtil.setString("last_unfinished_homework_check",
                    DateUtils.formatDate(new Date(), "yyyyMMdd"));
        }
    }
}

From source file:com.jtxdriggers.android.ventriloid.VentriloidService.java

private Notification createNotification(String text, short type, short id) {
    Intent notifIntent = new Intent(this, Connected.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    NotificationCompat.Builder notifBuilder = new NotificationCompat.Builder(VentriloidService.this);

    switch (type) {
    case VentriloEvents.V3_EVENT_LOGIN_COMPLETE:
    case VentriloEvents.V3_EVENT_USER_LOGIN:
    case VentriloEvents.V3_EVENT_USER_LOGOUT:
    case VentriloEvents.V3_EVENT_USER_CHAN_MOVE:
        notifBuilder.setSmallIcon(R.drawable.headset).setContentText("Connected to " + server.getServername())
                .setTicker(text).setContentTitle("Ventriloid").setOngoing(true).setAutoCancel(false);
        break;/*from   ww  w .  j a v a  2  s .  c o m*/
    case VentriloEvents.V3_EVENT_USER_PAGE:
        notifBuilder.setSmallIcon(R.drawable.about).setContentText(text).setTicker(text)
                .setContentTitle("Page Received").setAutoCancel(true).setOngoing(false)
                .setDefaults(Notification.DEFAULT_VIBRATE);
        break;
    case VentriloEvents.V3_EVENT_PRIVATE_CHAT_MESSAGE:
        notifIntent.putExtra("id", id);
        Item.User u = items.getUserById(id);
        notifBuilder.setSmallIcon(R.drawable.comment).setContentText(text).setTicker(text)
                .setContentTitle(u.name + " - Private Message").setOnlyAlertOnce(true).setAutoCancel(true)
                .setOngoing(false).setDefaults(Notification.DEFAULT_ALL);
        break;
    case VentriloEvents.V3_EVENT_DISCONNECT:
        notifIntent = new Intent(this, Main.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        notifBuilder.setSmallIcon(R.drawable.headset).setContentTitle("Disconnected from Server")
                .setContentText(text).setOngoing(true).setAutoCancel(false);
        if (text.contains(10 + ""))
            notifBuilder.setTicker("Reconnecting to Server");
        else if (text.contains("call"))
            notifBuilder.setTicker(text);
        break;
    }

    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notifIntent,
            PendingIntent.FLAG_CANCEL_CURRENT);
    notifBuilder.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.launcher))
            .setContentIntent(pendingIntent);

    return notifBuilder.getNotification();
}

From source file:com.xclong.vehiclemonitordemo.service.CommunicationService.java

private void sendNotifications(VehicledInfo vehicledInfo, Conversations.Conversion conversation) {
    PendingIntent pendingIntent = PendingIntent.getBroadcast(getApplicationContext(),
            conversation.getConversation_id(), getMessageReadIntent(conversation.getConversation_id()),
            PendingIntent.FLAG_UPDATE_CURRENT);

    NotificationCompat.CarExtender.UnreadConversation.Builder unreadConvBuilder = new NotificationCompat.CarExtender.UnreadConversation.Builder(
            "").setLatestTimestamp(conversation.getTimestamp()).setReadPendingIntent(pendingIntent);

    StringBuilder messageForNotification = new StringBuilder();
    for (Iterator<String> messages = conversation.getMessages().iterator(); messages.hasNext();) {
        String message = messages.next();
        unreadConvBuilder.addMessage(message);
        messageForNotification.append(message);
        if (messages.hasNext()) {
            messageForNotification.append(EOL);
        }/* w w w .  ja v  a2 s  . c om*/
    }

    NotificationCompat.Builder builder = new NotificationCompat.Builder(getApplicationContext())
            .setSmallIcon(R.mipmap.ic_stat_action_report_problem)
            .setLargeIcon(BitmapFactory.decodeResource(getApplicationContext().getResources(),
                    R.mipmap.ic_stat_action_report_problem))
            .setContentText(messageForNotification.toString()).setWhen(conversation.getTimestamp())
            .setContentTitle(vehicledInfo.getCar_number())
            .setTicker(vehicledInfo.getCar_number() + "").setDefaults(Notification.DEFAULT_ALL)
            .setContentIntent(pendingIntent)
            .extend(new NotificationCompat.CarExtender().setUnreadConversation(unreadConvBuilder.build())
                    .setColor(getApplicationContext().getResources().getColor(R.color.colorPrimary)));

    /* MessageLogger.logMessage(getApplicationContext(), "Sending notification "
        + conversation.getConversationId() + " conversation: " + conversation);*/
    String[] datetime = vehicledInfo.getTime().split(" ");
    adao.add(new AbnormalInfo(conversation.getTitle(), conversation.getMessagesString(), datetime[0],
            datetime[1]));
    mNotificationManager.notify(conversation.getConversation_id(), builder.build());
}

From source file:com.free.searcher.MainFragment.java

private void setMood(int moodId, String text, boolean showTicker) {
    //        // In this sample, we'll use the same text for the ticker and the expanded notification
    //        CharSequence text = getText(textId);
    ////from  w w w .  j a va 2 s . co  m
    //        // choose the ticker text
    String tickerText = showTicker ? text : null;

    // Set the icon, scrolling text and timestamp
    Notification notification = new Notification(moodId, tickerText, System.currentTimeMillis());

    // Set the info for the views that show in the notification panel.
    //        notification.setLatestEventInfo(activity, "Searching finished",
    //                              text, makeMoodIntent(moodId));
    notification.defaults = Notification.DEFAULT_ALL;
    // Send the notification.
    // We use a layout id because it is a unique number.  We use it later to cancel.
    mNotificationManager.notify(MOOD_NOTIFICATIONS, notification);
}