Example usage for android.app Notification PRIORITY_LOW

List of usage examples for android.app Notification PRIORITY_LOW

Introduction

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

Prototype

int PRIORITY_LOW

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

Click Source Link

Document

Lower #priority , for items that are less important.

Usage

From source file:com.jjcamera.apps.iosched.service.SessionAlarmService.java

/**
 *  A starred session is about to end. Notify the user to provide session feedback.
 *  Constructs and triggers a system notification. Does nothing if the session has already
 *  concluded.//www.j a  v  a  2  s  .  c  om
 */
private void notifySessionFeedback(boolean debug) {
    LOGD(TAG, "Considering firing notification for session feedback.");

    if (debug) {
        LOGW(TAG, "Note: this is a debug notification.");
    }

    // Don't fire notification if this feature is disabled in settings
    if (!SettingsUtils.shouldShowSessionFeedbackReminders(this)) {
        LOGD(TAG, "Skipping session feedback notification. Disabled in settings.");
        return;
    }

    Cursor c = null;
    try {
        c = getContentResolver().query(ScheduleContract.Sessions.CONTENT_MY_SCHEDULE_URI,
                SessionsNeedingFeedbackQuery.PROJECTION, SessionsNeedingFeedbackQuery.WHERE_CLAUSE, null, null);
        if (c == null) {
            return;
        }

        FeedbackHelper feedbackHelper = new FeedbackHelper(this);

        List<String> needFeedbackIds = new ArrayList<String>();
        List<String> needFeedbackTitles = new ArrayList<String>();
        while (c.moveToNext()) {
            String sessionId = c.getString(SessionsNeedingFeedbackQuery.SESSION_ID);
            String sessionTitle = c.getString(SessionsNeedingFeedbackQuery.SESSION_TITLE);

            // Avoid repeated notifications.
            if (feedbackHelper.isFeedbackNotificationFiredForSession(sessionId)) {
                LOGD(TAG, "Skipping repeated session feedback notification for session '" + sessionTitle + "'");
                continue;
            }

            needFeedbackIds.add(sessionId);
            needFeedbackTitles.add(sessionTitle);
        }

        if (needFeedbackIds.size() == 0) {
            // the user has already been notified of all sessions needing feedback
            return;
        }

        LOGD(TAG, "Going forward with session feedback notification for " + needFeedbackIds.size()
                + " session(s).");

        final Resources res = getResources();

        // this is used to synchronize deletion of notifications on phone and wear
        Intent dismissalIntent = new Intent(ACTION_NOTIFICATION_DISMISSAL);
        // TODO: fix Wear dismiss integration
        //dismissalIntent.putExtra(KEY_SESSION_ID, sessionId);
        PendingIntent dismissalPendingIntent = PendingIntent.getService(this, (int) new Date().getTime(),
                dismissalIntent, PendingIntent.FLAG_UPDATE_CURRENT);

        String provideFeedbackTicker = res.getString(R.string.session_feedback_notification_ticker);
        NotificationCompat.Builder notifBuilder = new NotificationCompat.Builder(this)
                .setColor(getResources().getColor(R.color.theme_primary)).setContentText(provideFeedbackTicker)
                .setTicker(provideFeedbackTicker)
                .setLights(SessionAlarmService.NOTIFICATION_ARGB_COLOR,
                        SessionAlarmService.NOTIFICATION_LED_ON_MS, SessionAlarmService.NOTIFICATION_LED_OFF_MS)
                .setSmallIcon(R.drawable.ic_stat_notification).setPriority(Notification.PRIORITY_LOW)
                .setLocalOnly(true) // make it local to the phone
                .setDefaults(Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE)
                .setDeleteIntent(dismissalPendingIntent).setAutoCancel(true);

        if (needFeedbackIds.size() == 1) {
            // Only 1 session needs feedback
            Uri sessionUri = ScheduleContract.Sessions.buildSessionUri(needFeedbackIds.get(0));
            PendingIntent pi = TaskStackBuilder.create(this)
                    .addNextIntent(new Intent(this, MyScheduleActivity.class))
                    .addNextIntent(
                            new Intent(Intent.ACTION_VIEW, sessionUri, this, SessionFeedbackActivity.class))
                    .getPendingIntent(1, PendingIntent.FLAG_CANCEL_CURRENT);

            notifBuilder.setContentTitle(needFeedbackTitles.get(0)).setContentIntent(pi);
        } else {
            // Show information about several sessions that need feedback
            PendingIntent pi = TaskStackBuilder.create(this)
                    .addNextIntent(new Intent(this, MyScheduleActivity.class))
                    .getPendingIntent(1, PendingIntent.FLAG_CANCEL_CURRENT);

            NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle();
            inboxStyle.setBigContentTitle(provideFeedbackTicker);
            for (String title : needFeedbackTitles) {
                inboxStyle.addLine(title);
            }

            notifBuilder
                    .setContentTitle(getResources().getQuantityString(R.plurals.session_plurals,
                            needFeedbackIds.size(), needFeedbackIds.size()))
                    .setStyle(inboxStyle).setContentIntent(pi);
        }

        NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
        LOGD(TAG, "Now showing session feedback notification!");
        nm.notify(FEEDBACK_NOTIFICATION_ID, notifBuilder.build());

        /*for (int i = 0; i < needFeedbackIds.size(); i++) {
        setupNotificationOnWear(needFeedbackIds.get(i), null, needFeedbackTitles.get(i), null);
        feedbackHelper.setFeedbackNotificationAsFiredForSession(needFeedbackIds.get(i));
        }*/
    } finally {
        if (c != null) {
            try {
                c.close();
            } catch (Exception ignored) {
            }
        }
    }
}

From source file:com.google.samples.apps.iosched.service.SessionAlarmService.java

/**
 *  A starred session is about to end. Notify the user to provide session feedback.
 *  Constructs and triggers a system notification. Does nothing if the session has already
 *  concluded.//from   w  w  w.  ja va 2 s.co  m
 */
private void notifySessionFeedback(boolean debug) {
    LOGD(TAG, "Considering firing notification for session feedback.");

    if (debug) {
        LOGW(TAG, "Note: this is a debug notification.");
    }

    // Don't fire notification if this feature is disabled in settings
    if (!SettingsUtils.shouldShowSessionFeedbackReminders(this)) {
        LOGD(TAG, "Skipping session feedback notification. Disabled in settings.");
        return;
    }

    Cursor c = null;
    try {
        c = getContentResolver().query(ScheduleContract.Sessions.CONTENT_MY_SCHEDULE_URI,
                SessionsNeedingFeedbackQuery.PROJECTION, SessionsNeedingFeedbackQuery.WHERE_CLAUSE, null, null);
        if (c == null) {
            return;
        }

        FeedbackHelper feedbackHelper = new FeedbackHelper(this);

        List<String> needFeedbackIds = new ArrayList<String>();
        List<String> needFeedbackTitles = new ArrayList<String>();
        while (c.moveToNext()) {
            String sessionId = c.getString(SessionsNeedingFeedbackQuery.SESSION_ID);
            String sessionTitle = c.getString(SessionsNeedingFeedbackQuery.SESSION_TITLE);

            // Avoid repeated notifications.
            if (feedbackHelper.isFeedbackNotificationFiredForSession(sessionId)) {
                LOGD(TAG, "Skipping repeated session feedback notification for session '" + sessionTitle + "'");
                continue;
            }

            needFeedbackIds.add(sessionId);
            needFeedbackTitles.add(sessionTitle);
        }

        if (needFeedbackIds.size() == 0) {
            // the user has already been notified of all sessions needing feedback
            return;
        }

        LOGD(TAG, "Going forward with session feedback notification for " + needFeedbackIds.size()
                + " session(s).");

        final Resources res = getResources();

        // this is used to synchronize deletion of notifications on phone and wear
        Intent dismissalIntent = new Intent(ACTION_NOTIFICATION_DISMISSAL);
        // TODO: fix Wear dismiss integration
        //dismissalIntent.putExtra(KEY_SESSION_ID, sessionId);
        PendingIntent dismissalPendingIntent = PendingIntent.getService(this, (int) new Date().getTime(),
                dismissalIntent, PendingIntent.FLAG_UPDATE_CURRENT);

        String provideFeedbackTicker = res.getString(R.string.session_feedback_notification_ticker);
        NotificationCompat.Builder notifBuilder = new NotificationCompat.Builder(this)
                .setColor(getResources().getColor(R.color.theme_primary)).setContentText(provideFeedbackTicker)
                .setTicker(provideFeedbackTicker)
                .setLights(SessionAlarmService.NOTIFICATION_ARGB_COLOR,
                        SessionAlarmService.NOTIFICATION_LED_ON_MS, SessionAlarmService.NOTIFICATION_LED_OFF_MS)
                .setSmallIcon(R.drawable.ic_stat_notification).setPriority(Notification.PRIORITY_LOW)
                .setLocalOnly(true) // make it local to the phone
                .setDefaults(Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE)
                .setDeleteIntent(dismissalPendingIntent).setAutoCancel(true);

        if (needFeedbackIds.size() == 1) {
            // Only 1 session needs feedback
            Uri sessionUri = ScheduleContract.Sessions.buildSessionUri(needFeedbackIds.get(0));
            PendingIntent pi = TaskStackBuilder.create(this)
                    .addNextIntent(new Intent(this, MyScheduleActivity.class))
                    .addNextIntent(
                            new Intent(Intent.ACTION_VIEW, sessionUri, this, SessionFeedbackActivity.class))
                    .getPendingIntent(1, PendingIntent.FLAG_CANCEL_CURRENT);

            notifBuilder.setContentTitle(needFeedbackTitles.get(0)).setContentIntent(pi);
        } else {
            // Show information about several sessions that need feedback
            PendingIntent pi = TaskStackBuilder.create(this)
                    .addNextIntent(new Intent(this, MyScheduleActivity.class))
                    .getPendingIntent(1, PendingIntent.FLAG_CANCEL_CURRENT);

            NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle();
            inboxStyle.setBigContentTitle(provideFeedbackTicker);
            for (String title : needFeedbackTitles) {
                inboxStyle.addLine(title);
            }

            notifBuilder
                    .setContentTitle(getResources().getQuantityString(R.plurals.session_plurals,
                            needFeedbackIds.size(), needFeedbackIds.size()))
                    .setStyle(inboxStyle).setContentIntent(pi);
        }

        NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
        LOGD(TAG, "Now showing session feedback notification!");
        nm.notify(FEEDBACK_NOTIFICATION_ID, notifBuilder.build());

        for (int i = 0; i < needFeedbackIds.size(); i++) {
            setupNotificationOnWear(needFeedbackIds.get(i), null, needFeedbackTitles.get(i), null);
            feedbackHelper.setFeedbackNotificationAsFiredForSession(needFeedbackIds.get(i));
        }
    } finally {
        if (c != null) {
            try {
                c.close();
            } catch (Exception ignored) {
            }
        }
    }
}

From source file:com.saarang.samples.apps.iosched.service.SessionAlarmService.java

private void notifySessionFeedback(boolean debug) {
    LogUtils.LOGD(TAG, "Considering firing notification for session feedback.");

    if (debug) {//from  ww  w.j a  v  a  2 s.  c o  m
        LogUtils.LOGD(TAG, "Note: this is a debug notification.");
    }

    // Don't fire notification if this feature is disabled in settings
    if (!PrefUtils.shouldShowSessionFeedbackReminders(this)) {
        LogUtils.LOGD(TAG, "Skipping session feedback notification. Disabled in settings.");
        return;
    }

    final Cursor c = getContentResolver().query(ScheduleContract.Sessions.CONTENT_MY_SCHEDULE_URI,
            SessionsNeedingFeedbackQuery.PROJECTION, SessionsNeedingFeedbackQuery.WHERE_CLAUSE, null, null);
    if (c == null) {
        return;
    }

    List<String> needFeedbackIds = new ArrayList<String>();
    List<String> needFeedbackTitles = new ArrayList<String>();
    while (c.moveToNext()) {
        String sessionId = c.getString(SessionsNeedingFeedbackQuery.SESSION_ID);
        String sessionTitle = c.getString(SessionsNeedingFeedbackQuery.SESSION_TITLE);

        // Avoid repeated notifications.
        if (UIUtils.isFeedbackNotificationFiredForSession(this, sessionId)) {
            LogUtils.LOGD(TAG,
                    "Skipping repeated session feedback notification for session '" + sessionTitle + "'");
            continue;
        }

        needFeedbackIds.add(sessionId);
        needFeedbackTitles.add(sessionTitle);
    }

    if (needFeedbackIds.size() == 0) {
        // the user has already been notified of all sessions needing feedback
        return;
    }

    LogUtils.LOGD(TAG,
            "Going forward with session feedback notification for " + needFeedbackIds.size() + " session(s).");

    final Resources res = getResources();

    // this is used to synchronize deletion of notifications on phone and wear
    Intent dismissalIntent = new Intent(ACTION_NOTIFICATION_DISMISSAL);
    // TODO: fix Wear dismiss integration
    //dismissalIntent.putExtra(KEY_SESSION_ID, sessionId);
    PendingIntent dismissalPendingIntent = PendingIntent.getService(this, (int) new Date().getTime(),
            dismissalIntent, PendingIntent.FLAG_UPDATE_CURRENT);

    String provideFeedbackTicker = res
            .getString(com.saarang.samples.apps.iosched.R.string.session_feedback_notification_ticker);
    NotificationCompat.Builder notifBuilder = new NotificationCompat.Builder(this)
            .setColor(getResources().getColor(com.saarang.samples.apps.iosched.R.color.theme_primary))
            .setContentText(provideFeedbackTicker).setTicker(provideFeedbackTicker)
            .setLights(SessionAlarmService.NOTIFICATION_ARGB_COLOR, SessionAlarmService.NOTIFICATION_LED_ON_MS,
                    SessionAlarmService.NOTIFICATION_LED_OFF_MS)
            .setSmallIcon(com.saarang.samples.apps.iosched.R.drawable.ic_stat_notification)
            .setPriority(Notification.PRIORITY_LOW).setLocalOnly(true) // make it local to the phone
            .setDefaults(Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE)
            .setDeleteIntent(dismissalPendingIntent).setAutoCancel(true);

    if (needFeedbackIds.size() == 1) {
        // Only 1 session needs feedback
        Uri sessionUri = ScheduleContract.Sessions.buildSessionUri(needFeedbackIds.get(0));
        PendingIntent pi = TaskStackBuilder.create(this)
                .addNextIntent(new Intent(this, MyScheduleActivity.class))
                .addNextIntent(new Intent(Intent.ACTION_VIEW, sessionUri, this, SessionFeedbackActivity.class))
                .getPendingIntent(1, PendingIntent.FLAG_CANCEL_CURRENT);

        notifBuilder.setContentTitle(needFeedbackTitles.get(0)).setContentIntent(pi);
    } else {
        // Show information about several sessions that need feedback
        PendingIntent pi = TaskStackBuilder.create(this)
                .addNextIntent(new Intent(this, MyScheduleActivity.class))
                .getPendingIntent(1, PendingIntent.FLAG_CANCEL_CURRENT);

        NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle();
        inboxStyle.setBigContentTitle(provideFeedbackTicker);
        for (String title : needFeedbackTitles) {
            inboxStyle.addLine(title);
        }

        notifBuilder.setContentTitle(
                getResources().getQuantityString(com.saarang.samples.apps.iosched.R.plurals.session_plurals,
                        needFeedbackIds.size(), needFeedbackIds.size()))
                .setStyle(inboxStyle).setContentIntent(pi);
    }

    NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    LogUtils.LOGD(TAG, "Now showing session feedback notification!");
    nm.notify(FEEDBACK_NOTIFICATION_ID, notifBuilder.build());

    for (int i = 0; i < needFeedbackIds.size(); i++) {
        setupNotificationOnWear(needFeedbackIds.get(i), null, needFeedbackTitles.get(i), null);
    }
}

From source file:com.razza.apps.iosched.service.SessionAlarmService.java

/**
 *  A starred session is about to end. Notify the user to provide session feedback.
 *  Constructs and triggers a system notification. Does nothing if the session has already
 *  concluded.//  ww  w .j  a  v a2s  .c o  m
 */
private void notifySessionFeedback(boolean debug) {
    LogUtils.LOGD(TAG, "Considering firing notification for session feedback.");

    if (debug) {
        LogUtils.LOGW(TAG, "Note: this is a debug notification.");
    }

    // Don't fire notification if this feature is disabled in settings
    if (!SettingsUtils.shouldShowSessionFeedbackReminders(this)) {
        LogUtils.LOGD(TAG, "Skipping session feedback notification. Disabled in settings.");
        return;
    }

    Cursor c = null;
    try {
        c = getContentResolver().query(ScheduleContract.Sessions.CONTENT_MY_SCHEDULE_URI,
                SessionsNeedingFeedbackQuery.PROJECTION, SessionsNeedingFeedbackQuery.WHERE_CLAUSE, null, null);
        if (c == null) {
            return;
        }

        FeedbackHelper feedbackHelper = new FeedbackHelper(this);

        List<String> needFeedbackIds = new ArrayList<String>();
        List<String> needFeedbackTitles = new ArrayList<String>();
        while (c.moveToNext()) {
            String sessionId = c.getString(SessionsNeedingFeedbackQuery.SESSION_ID);
            String sessionTitle = c.getString(SessionsNeedingFeedbackQuery.SESSION_TITLE);

            // Avoid repeated notifications.
            if (feedbackHelper.isFeedbackNotificationFiredForSession(sessionId)) {
                LogUtils.LOGD(TAG,
                        "Skipping repeated session feedback notification for session '" + sessionTitle + "'");
                continue;
            }

            needFeedbackIds.add(sessionId);
            needFeedbackTitles.add(sessionTitle);
        }

        if (needFeedbackIds.size() == 0) {
            // the user has already been notified of all sessions needing feedback
            return;
        }

        LogUtils.LOGD(TAG, "Going forward with session feedback notification for " + needFeedbackIds.size()
                + " session(s).");

        final Resources res = getResources();

        // this is used to synchronize deletion of notifications on phone and wear
        Intent dismissalIntent = new Intent(ACTION_NOTIFICATION_DISMISSAL);
        // TODO: fix Wear dismiss integration
        //dismissalIntent.putExtra(KEY_SESSION_ID, sessionId);
        PendingIntent dismissalPendingIntent = PendingIntent.getService(this, (int) new Date().getTime(),
                dismissalIntent, PendingIntent.FLAG_UPDATE_CURRENT);

        String provideFeedbackTicker = res.getString(R.string.session_feedback_notification_ticker);
        NotificationCompat.Builder notifBuilder = new NotificationCompat.Builder(this)
                .setColor(getResources().getColor(R.color.theme_primary)).setContentText(provideFeedbackTicker)
                .setTicker(provideFeedbackTicker)
                .setLights(SessionAlarmService.NOTIFICATION_ARGB_COLOR,
                        SessionAlarmService.NOTIFICATION_LED_ON_MS, SessionAlarmService.NOTIFICATION_LED_OFF_MS)
                .setSmallIcon(R.drawable.ic_stat_notification).setPriority(Notification.PRIORITY_LOW)
                .setLocalOnly(true) // make it local to the phone
                .setDefaults(Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE)
                .setDeleteIntent(dismissalPendingIntent).setAutoCancel(true);

        if (needFeedbackIds.size() == 1) {
            // Only 1 session needs feedback
            Uri sessionUri = ScheduleContract.Sessions.buildSessionUri(needFeedbackIds.get(0));
            PendingIntent pi = TaskStackBuilder.create(this)
                    .addNextIntent(new Intent(this, MyScheduleActivity.class))
                    .addNextIntent(
                            new Intent(Intent.ACTION_VIEW, sessionUri, this, SessionFeedbackActivity.class))
                    .getPendingIntent(1, PendingIntent.FLAG_CANCEL_CURRENT);

            notifBuilder.setContentTitle(needFeedbackTitles.get(0)).setContentIntent(pi);
        } else {
            // Show information about several sessions that need feedback
            PendingIntent pi = TaskStackBuilder.create(this)
                    .addNextIntent(new Intent(this, MyScheduleActivity.class))
                    .getPendingIntent(1, PendingIntent.FLAG_CANCEL_CURRENT);

            NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle();
            inboxStyle.setBigContentTitle(provideFeedbackTicker);
            for (String title : needFeedbackTitles) {
                inboxStyle.addLine(title);
            }

            notifBuilder
                    .setContentTitle(getResources().getQuantityString(R.plurals.session_plurals,
                            needFeedbackIds.size(), needFeedbackIds.size()))
                    .setStyle(inboxStyle).setContentIntent(pi);
        }

        NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
        LogUtils.LOGD(TAG, "Now showing session feedback notification!");
        nm.notify(FEEDBACK_NOTIFICATION_ID, notifBuilder.build());

        for (int i = 0; i < needFeedbackIds.size(); i++) {
            setupNotificationOnWear(needFeedbackIds.get(i), null, needFeedbackTitles.get(i), null);
            feedbackHelper.setFeedbackNotificationAsFiredForSession(needFeedbackIds.get(i));
        }
    } finally {
        if (c != null) {
            try {
                c.close();
            } catch (Exception ignored) {
            }
        }
    }
}

From source file:com.ibm.mobilefirstplatform.clientsdk.android.push.api.MFPPushIntentService.java

private int getPriorityOfMessage(MFPInternalPushMessage message) {
    String priorityFromServer = message.getPriority();
    MFPPushNotificationOptions options = MFPPush.getInstance().getNotificationOptions();
    int priorityPreSetValue = 0;

    if (options != null && options.getPriority() != null) {
        priorityPreSetValue = options.getPriority().getValue();
    }/*from  w  ww  .  j av  a 2  s .c  om*/

    if (priorityFromServer != null) {
        if (priorityFromServer.equalsIgnoreCase(MFPPushConstants.PRIORITY_MAX)) {
            return Notification.PRIORITY_MAX;
        } else if (priorityFromServer.equalsIgnoreCase(MFPPushConstants.PRIORITY_MIN)) {
            return Notification.PRIORITY_MIN;
        } else if (priorityFromServer.equalsIgnoreCase(MFPPushConstants.PRIORITY_HIGH)) {
            return Notification.PRIORITY_HIGH;
        } else if (priorityFromServer.equalsIgnoreCase(MFPPushConstants.PRIORITY_LOW)) {
            return Notification.PRIORITY_LOW;
        }
    } else if (priorityPreSetValue != 0) {
        return priorityPreSetValue;
    }
    return Notification.PRIORITY_DEFAULT;
}

From source file:de.mangelow.throughput.NotificationService.java

@SuppressWarnings("deprecation")
private void modifyNotification(int drawable, String ticker, String title, String subtitle, Intent i) {

    boolean showticker = MainActivity.loadBooleanPref(context, MainActivity.SHOWTICKER,
            MainActivity.SHOWTICKER_DEFAULT);
    if (!showticker)
        ticker = null;/* ww  w  . j a v a 2  s. co m*/

    NotificationManager nmanager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    PendingIntent pi = PendingIntent.getActivity(this, 0, i, NOTIFICATION_ID);
    Notification n = null;

    if (Build.VERSION.SDK_INT < 11) {

        n = new Notification(drawable, ticker, System.currentTimeMillis());
        n.flags |= Notification.FLAG_NO_CLEAR;
        n.setLatestEventInfo(this, title, subtitle, pi);

    } else {

        if (nb == null) {
            nb = new Notification.Builder(context);
            nb.setPriority(Notification.PRIORITY_LOW);
            nb.setAutoCancel(true);
        }

        nb.setSmallIcon(drawable);
        if (ticker != null)
            nb.setTicker(ticker);
        nb.setContentTitle(title);
        nb.setContentText(subtitle);
        nb.setContentIntent(pi);

        n = nb.build();
        n.flags = Notification.FLAG_NO_CLEAR;

    }

    nmanager.notify(NOTIFICATION_ID, n);

    //

    if (mResultReceiver != null) {

        Bundle bundle = new Bundle();
        bundle.putInt("drawable", drawable);
        bundle.putString("title", title);
        bundle.putString("subtitle", subtitle);
        mResultReceiver.send(0, bundle);

    }

}

From source file:cw.kop.autobackground.files.DownloadThread.java

private void finish() {
    if (AppSettings.useDownloadNotification()) {
        Notification.Builder notifyComplete = new Notification.Builder(appContext)
                .setContentTitle("Download Completed")
                .setContentText("AutoBackground downloaded " + totalDownloaded + " images")
                .setSmallIcon(R.drawable.ic_photo_white_24dp);

        Notification notification;

        if (Build.VERSION.SDK_INT >= 16) {
            notifyComplete.setPriority(Notification.PRIORITY_LOW);
            Notification.InboxStyle inboxStyle = new Notification.InboxStyle();
            inboxStyle.setBigContentTitle("Downloaded Image Details:");

            inboxStyle.addLine("Total images enabled: " + FileHandler.getBitmapList().size());

            for (String detail : imageDetails.split(AppSettings.DATA_SPLITTER)) {
                inboxStyle.addLine(detail);
            }/*from  w  w w .  j  ava2s .  c o m*/

            notifyComplete.setStyle(inboxStyle);
            notification = notifyComplete.build();
        } else {
            notification = notifyComplete.getNotification();
        }

        notificationManager.cancel(NOTIFICATION_ID);
        notificationManager.notify(NOTIFICATION_ID, notification);
    }

    Intent cycleIntent = new Intent();
    cycleIntent.setAction(LiveWallpaperService.CYCLE_IMAGE);
    cycleIntent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
    appContext.sendBroadcast(cycleIntent);

    Intent resetDownloadIntent = new Intent(FileHandler.DOWNLOAD_TERMINATED);
    LocalBroadcastManager.getInstance(appContext).sendBroadcast(resetDownloadIntent);

    Intent intent = new Intent();
    intent.setAction(LiveWallpaperService.UPDATE_NOTIFICATION);
    intent.putExtra("use", AppSettings.useNotification());
    appContext.sendBroadcast(intent);

    AppSettings.checkUsedLinksSize();
    appContext = null;

    Log.i(TAG, "Download Finished");
    FileHandler.setIsDownloading(false);
}