public void notifyPictureSuccess(int picSize, long picLength) { String title = "图片离线完成"; String content = String.format("%s张图片,节省流量%s", String.valueOf(picSize) , AisenUtils.getUnit(picLength)); NotificationCompat.Builder builder = new NotificationCompat.Builder(context); builder.setSmallIcon(R.drawable.statusbar_ic_send_success) .setContentTitle(title) .setAutoCancel(true) .setContentText(content); OfflineNotifier.this.notify(OfflinePicture, 0, builder); }
public void notifyStatusSuccess(int groupSize, int statusSize, long statusLength) { String title = String.format("%d个分组离线完成", groupSize); String content = String.format("共%d条微博,节省流量%s", statusSize, AisenUtils.getUnit(statusLength)); NotificationCompat.Builder builder = new NotificationCompat.Builder(context); builder.setSmallIcon(R.drawable.statusbar_ic_send_success) .setContentTitle(title) .setAutoCancel(true) .setContentText(content); notify(OfflineStatus, 0, builder); }
public void notifyStatus(Group group, long offlineLengh) { String title = String.format("离线分组[%s]", group.getName()); String content = String.format("节省流量%s", AisenUtils.getUnit(offlineLengh)); NotificationCompat.Builder builder = new NotificationCompat.Builder(context); builder.setSmallIcon(R.drawable.statusbar_ic_send_success) .setContentTitle(title) .setAutoCancel(true) .setContentText(content); notify(OfflineStatus, 0, builder); }
@Override public boolean onStartJob(JobParameters params) { NotificationManager mgr= (NotificationManager)getSystemService(NOTIFICATION_SERVICE); if (Build.VERSION.SDK_INT>=Build.VERSION_CODES.O && mgr.getNotificationChannel(CHANNEL_WHATEVER)==null) { mgr.createNotificationChannel(new NotificationChannel(CHANNEL_WHATEVER, "Whatever", NotificationManager.IMPORTANCE_DEFAULT)); } NotificationCompat.Builder b= new NotificationCompat.Builder(this, CHANNEL_WHATEVER) .setAutoCancel(true) .setDefaults(Notification.DEFAULT_ALL) .setContentTitle("You added a contact!") .setSmallIcon(android.R.drawable.stat_notify_more); mgr.notify(NOTIFY_ID, b.build()); return(false); }
private NotificationCompat.Builder buildNormal() { NotificationCompat.Builder b= new NotificationCompat.Builder(this, CHANNEL_WHATEVER); b.setAutoCancel(true) .setDefaults(Notification.DEFAULT_ALL) .setContentTitle(getString(R.string.download_complete)) .setContentText(getString(R.string.fun)) .setContentIntent(buildPendingIntent(Settings.ACTION_SECURITY_SETTINGS)) .setSmallIcon(android.R.drawable.stat_sys_download_done) .setTicker(getString(R.string.download_complete)) .setPriority(NotificationCompat.PRIORITY_DEFAULT) .setLocalOnly(true) .addAction(android.R.drawable.ic_media_play, getString(R.string.play), buildPendingIntent(Settings.ACTION_SETTINGS)); return(b); }
public void notifyPrePublish(PublishBean bean) { Logger.d(TAG, "notifyPrePublish-" + bean.getText()); NotificationCompat.Builder builder = new NotificationCompat.Builder(context); builder.setSmallIcon(R.drawable.statusbar_ic_sending).setContentTitle(context.getString(R.string.notifer_cancel_publish)) .setContentText(getContentText(bean)) .setTicker(getContentTitle(bean, 0)); Intent intent = new Intent(GlobalContext.getInstance(), PublishService.class); intent.setAction("org.aisen.weibo.sina.Cancel"); PendingIntent contentIntent = PendingIntent.getService(GlobalContext.getInstance(), 0, intent, PendingIntent.FLAG_CANCEL_CURRENT); builder.setContentIntent(contentIntent).setAutoCancel(true); Logger.d(TAG, "notify PrePublish"); notify(getRequest(bean), 0, builder); }
@Subscribe public void onDeadEvent(DeadEvent braiiiiiiinz) { RandomEvent original=(RandomEvent)braiiiiiiinz.event; NotificationCompat.Builder b=new NotificationCompat.Builder(this); Intent ui=new Intent(this, EventDemoActivity.class); b.setAutoCancel(true).setDefaults(Notification.DEFAULT_SOUND) .setContentTitle(getString(R.string.notif_title)) .setContentText(Integer.toHexString(original.value)) .setSmallIcon(android.R.drawable.stat_notify_more) .setTicker(getString(R.string.notif_title)) .setContentIntent(PendingIntent.getActivity(this, 0, ui, 0)); NotificationManager mgr= (NotificationManager)getSystemService(NOTIFICATION_SERVICE); mgr.notify(NOTIFY_ID, b.build()); } }
private NotificationCompat.Builder buildNormal() { NotificationCompat.Builder b= new NotificationCompat.Builder(this, CHANNEL_WHATEVER); b.setAutoCancel(true) .setDefaults(Notification.DEFAULT_ALL) .setContentTitle(getString(R.string.download_complete)) .setContentText(getString(R.string.fun)) .setContentIntent(buildPendingIntent(Settings.ACTION_SECURITY_SETTINGS)) .setSmallIcon(android.R.drawable.stat_sys_download_done) .setNumber(5) .setFullScreenIntent(buildPendingIntent(Settings.ACTION_DATE_SETTINGS), true) .addAction(android.R.drawable.ic_media_play, getString(R.string.play), buildPendingIntent(Settings.ACTION_SETTINGS)); return(b); }
public void notifyTimingPublish(PublishBean bean) { NotificationCompat.Builder builder = new NotificationCompat.Builder(context); builder.setSmallIcon(R.drawable.statusbar_ic_sending) .setContentTitle(context.getString(R.string.notifer_timging_draft)) .setAutoCancel(true) .setContentText(bean.getText()) .setTicker(context.getString(R.string.notifer_timging_draft)); notify(121212, 5, builder); // 延迟一秒后取消通知 GlobalContext.getInstance().getHandler().removeCallbacks(removeTimingPublishRunnable); GlobalContext.getInstance().getHandler().postDelayed(removeTimingPublishRunnable, 1000); }
private NotificationCompat.Builder buildBase(Context ctxt, String channel, int titleId) { NotificationCompat.Builder b= new NotificationCompat.Builder(ctxt, channel); b.setAutoCancel(true) .setDefaults(Notification.DEFAULT_ALL) .setContentTitle(ctxt.getString(titleId)) .setContentIntent(buildPendingIntent(ctxt, Settings.ACTION_SECURITY_SETTINGS)) .setSmallIcon(android.R.drawable.stat_sys_download_done) .addAction(android.R.drawable.ic_media_play, ctxt.getString(R.string.play), buildPendingIntent(ctxt, Settings.ACTION_SETTINGS)); return(b); }
private NotificationCompat.Builder buildNormal() { NotificationCompat.Builder b= new NotificationCompat.Builder(this, CHANNEL_WHATEVER); b.setAutoCancel(true) .setContentTitle(getString(R.string.download_complete)) .setContentText(getString(R.string.fun)) .setContentIntent(buildPendingIntent(Settings.ACTION_SECURITY_SETTINGS)) .setSmallIcon(android.R.drawable.stat_sys_download_done) .setPriority(Notification.PRIORITY_HIGH) .addAction(android.R.drawable.ic_media_play, getString(R.string.play), buildPendingIntent(Settings.ACTION_SETTINGS)); return(b); }
@Override public void taskStart(@NonNull DownloadTask task) { Log.d("NotificationActivity", "taskStart"); builder.setTicker("taskStart"); builder.setOngoing(true); builder.setAutoCancel(false); builder.setContentText("The task is started"); builder.setProgress(0, 0, true); manager.notify(task.getId(), builder.build()); }
@Test public void buildSummaryNotification_withPrivacyModeActive() throws Exception { K9.setNotificationHideSubject(NotificationHideSubject.ALWAYS); Notification result = notifications.buildSummaryNotification(account, notificationData, false); verify(builder).setSmallIcon(resourceProvider.getIconNewMail()); verify(builder).setColor(ACCOUNT_COLOR); verify(builder).setAutoCancel(true); verify(builder).setNumber(UNREAD_MESSAGE_COUNT); verify(builder).setTicker("New mail"); verify(builder).setContentText("New mail"); verify(builder).setContentTitle(UNREAD_MESSAGE_COUNT + " Unread (" + ACCOUNT_NAME + ")"); verify(lockScreenNotification).configureLockScreenNotification(builder, notificationData); assertEquals(FAKE_NOTIFICATION, result); }
private NotificationCompat.Builder buildNormal() { NotificationCompat.Builder b= new NotificationCompat.Builder(this, CHANNEL_WHATEVER); b.setAutoCancel(true) .setDefaults(Notification.DEFAULT_ALL) .setContentTitle(getString(R.string.download_complete)) .setContentText(getString(R.string.fun)) .setContentIntent(buildPendingIntent(Settings.ACTION_SECURITY_SETTINGS)) .setSmallIcon(android.R.drawable.stat_sys_download_done) .addAction(android.R.drawable.ic_media_play, getString(R.string.play), buildPendingIntent(Settings.ACTION_SETTINGS)); return(b); }
private NotificationCompat.Builder buildNormal() { NotificationCompat.Builder b= new NotificationCompat.Builder(this, CHANNEL_WHATEVER); b.setAutoCancel(true) .setDefaults(Notification.DEFAULT_ALL) .setContentTitle(getString(R.string.download_complete)) .setContentText(getString(R.string.fun)) .setContentIntent(buildPendingIntent(Settings.ACTION_SECURITY_SETTINGS)) .setSmallIcon(android.R.drawable.stat_sys_download_done) .addAction(android.R.drawable.ic_media_play, getString(R.string.play), buildPendingIntent(Settings.ACTION_SETTINGS)); return(b); }
private NotificationCompat.Builder buildNormal() { NotificationCompat.Builder b= new NotificationCompat.Builder(this, CHANNEL_WHATEVER); b.setAutoCancel(true) .setDefaults(Notification.DEFAULT_ALL) .setContentTitle(getString(R.string.download_complete)) .setContentText(getString(R.string.fun)) .setContentIntent(buildPendingIntent(Settings.ACTION_SECURITY_SETTINGS)) .setSmallIcon(android.R.drawable.stat_sys_download_done) .setGroup(GROUP_SAMPLE) .setGroupSummary(true); return(b); }
@Test public void testCreateAndInitializeNotificationBuilder() throws Exception { Account account = createFakeAccount(); Builder builder = notifications.createAndInitializeNotificationBuilder(account); verify(builder).setSmallIcon(resourceProvider.getIconNewMail()); verify(builder).setColor(ACCOUNT_COLOR); verify(builder).setAutoCancel(true); }
protected NotificationCompat.Builder createAndInitializeNotificationBuilder(Account account) { return notificationHelper.createNotificationBuilder(account, NotificationChannelManager.ChannelType.MESSAGES) .setSmallIcon(getNewMailNotificationIcon()) .setColor(account.getChipColor()) .setWhen(System.currentTimeMillis()) .setAutoCancel(true) .setCategory(NotificationCompat.CATEGORY_EMAIL); }
private void showWearTwo() { NotificationCompat.Builder b= new NotificationCompat.Builder(this, CHANNEL_WHATEVER); b.setAutoCancel(true) .setDefaults(Notification.DEFAULT_ALL) .setContentTitle(getString(R.string.another_entry)) .setContentIntent(buildPendingIntent(Settings.ACTION_SECURITY_SETTINGS)) .setSmallIcon(android.R.drawable.stat_sys_download_done) .setGroup(GROUP_SAMPLE); mgrCompat.notify(NOTIFY_ID3, b.build()); }
private void showWearOne() { NotificationCompat.Builder b= new NotificationCompat.Builder(this, CHANNEL_WHATEVER); b.setAutoCancel(true) .setDefaults(Notification.DEFAULT_ALL) .setContentTitle(getString(R.string.entry)) .setContentIntent(buildPendingIntent(Settings.ACTION_SECURITY_SETTINGS)) .setSmallIcon(android.R.drawable.stat_sys_download_done) .setGroup(GROUP_SAMPLE); mgrCompat.notify(NOTIFY_ID2, b.build()); }