Example usage for android.app Notification PRIORITY_HIGH

List of usage examples for android.app Notification PRIORITY_HIGH

Introduction

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

Prototype

int PRIORITY_HIGH

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

Click Source Link

Document

Higher #priority , for more important notifications or alerts.

Usage

From source file:com.mishiranu.dashchan.ui.navigator.NavigatorActivity.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override//from  w ww .j  a  v a 2  s.  c  o m
public void onReadUpdateComplete(ReadUpdateTask.UpdateDataMap updateDataMap) {
    readUpdateTask = null;
    if (updateDataMap == null) {
        return;
    }
    Preferences.setLastUpdateCheck(System.currentTimeMillis());
    int count = PreferencesActivity.checkNewVersions(updateDataMap);
    if (count <= 0) {
        return;
    }
    Notification.Builder builder = new Notification.Builder(this);
    builder.setSmallIcon(R.drawable.ic_new_releases_white_24dp);
    String text = getString(R.string.text_updates_available_format, count);
    if (C.API_LOLLIPOP) {
        builder.setColor(ResourceUtils.getColor(this, android.R.attr.colorAccent));
        builder.setPriority(Notification.PRIORITY_HIGH);
        builder.setVibrate(new long[0]);
    } else {
        builder.setTicker(text);
    }
    builder.setContentTitle(getString(R.string.text_app_name_update, getString(R.string.const_app_name)));
    builder.setContentText(text);
    builder.setContentIntent(PendingIntent.getActivity(this, 0,
            PreferencesActivity.createUpdateIntent(this, updateDataMap).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK),
            PendingIntent.FLAG_UPDATE_CURRENT));
    builder.setAutoCancel(true);
    NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    notificationManager.notify(C.NOTIFICATION_TAG_UPDATE, 0, builder.build());
}