private void setMood(int moodId, int textId, boolean showTicker) { // In this sample, we'll use the same text for the ticker and the expanded notification CharSequence text = getText(textId); // choose the ticker text String tickerText = showTicker ? getString(textId) : 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(this, getText(R.string.status_bar_notifications_mood_title), text, makeMoodIntent(moodId)); // 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); }
private void setMood(int moodId, int textId, boolean showTicker) { // In this sample, we'll use the same text for the ticker and the expanded notification CharSequence text = getText(textId); // In this sample, we'll use this text for the title of the notification CharSequence title = getText(R.string.status_bar_notifications_mood_title); // Set the info for the views that show in the notification panel. Notification.Builder notifBuidler = new Notification.Builder(this) // the context to use .setSmallIcon(moodId) // the status icon .setWhen(System.currentTimeMillis()) // the timestamp for the notification .setContentTitle(title) // the title for the notification .setContentText(text) // the details to display in the notification .setContentIntent(makeMoodIntent(moodId)); // The intent to send clicked if (showTicker) { // include the ticker text notifBuidler.setTicker(getString(textId)); } // Send the notification. // We use a layout id because it is a unique number. We use it later to cancel. mNotificationManager.notify(MOOD_NOTIFICATIONS, notifBuidler.build()); }