Java Code Examples for android.support.v7.app.NotificationCompat#InboxStyle
The following examples show how to use
android.support.v7.app.NotificationCompat#InboxStyle .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NotifyUtil0.java From NotifyUtil with Apache License 2.0 | 5 votes |
/** * 进行多项设置的通知(在小米上似乎不能设置大图标,系统默认大图标为应用图标) * * @param pendingIntent * @param smallIcon * @param ticker * @param title * @param content */ public void notify_mailbox(PendingIntent pendingIntent, int smallIcon, int largeIcon, ArrayList<String> messageList, String ticker, String title, String content, boolean sound, boolean vibrate, boolean lights) { setCompatBuilder(pendingIntent, smallIcon, ticker, title, content, sound, vibrate, lights); // 将Ongoing设为true 那么notification将不能滑动删除 //cBuilder.setOngoing(true); /** // 删除时 Intent deleteIntent = new Intent(mContext, DeleteService.class); int deleteCode = (int) SystemClock.uptimeMillis(); // 删除时开启一个服务 PendingIntent deletePendingIntent = PendingIntent.getService(mContext, deleteCode, deleteIntent, PendingIntent.FLAG_UPDATE_CURRENT); cBuilder.setDeleteIntent(deletePendingIntent); **/ Bitmap bitmap = BitmapFactory.decodeResource(mContext.getResources(), largeIcon); cBuilder.setLargeIcon(bitmap); cBuilder.setDefaults(Notification.DEFAULT_ALL);// 设置使用默认的声音 //cBuilder.setVibrate(new long[]{0, 100, 200, 300});// 设置自定义的振动 cBuilder.setAutoCancel(true); // builder.setSound(Uri.parse("file:///sdcard/click.mp3")); // 设置通知样式为收件箱样式,在通知中心中两指往外拉动,就能出线更多内容,但是很少见 //cBuilder.setNumber(messageList.size()); NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle(); for (String msg : messageList) { inboxStyle.addLine(msg); } inboxStyle.setSummaryText("[" + messageList.size() + "条]" + title); cBuilder.setStyle(inboxStyle); sent(); }
Example 2
Source File: MailboxBuilder.java From NotifyUtil with Apache License 2.0 | 5 votes |
@Override public void build() { super.build(); NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle(); for (String msg : messageList) { inboxStyle.addLine(msg); } String text = "[" + messageList.size() + "]条信息"; inboxStyle.setSummaryText(text); cBuilder.setStyle(inboxStyle); cBuilder.setContentText("你有"+text); if(TextUtils.isEmpty(ticker)){ cBuilder.setTicker(text); } }
Example 3
Source File: NotifyUtil.java From NotifyUtil with Apache License 2.0 | 5 votes |
/** * 进行多项设置的通知(在小米上似乎不能设置大图标,系统默认大图标为应用图标) * * @param pendingIntent * @param smallIcon * @param ticker * @param title * @param content */ public void notify_mailbox(PendingIntent pendingIntent, int smallIcon, int largeIcon, ArrayList<String> messageList, String ticker, String title, String content, boolean sound, boolean vibrate, boolean lights) { setCompatBuilder(pendingIntent, smallIcon, ticker, title, content, sound, vibrate, lights); // 将Ongoing设为true 那么notification将不能滑动删除 //cBuilder.setOngoing(true); /** // 删除时 Intent deleteIntent = new Intent(mContext, DeleteService.class); int deleteCode = (int) SystemClock.uptimeMillis(); // 删除时开启一个服务 PendingIntent deletePendingIntent = PendingIntent.getService(mContext, deleteCode, deleteIntent, PendingIntent.FLAG_UPDATE_CURRENT); cBuilder.setDeleteIntent(deletePendingIntent); **/ Bitmap bitmap = BitmapFactory.decodeResource(mContext.getResources(), largeIcon); cBuilder.setLargeIcon(bitmap); cBuilder.setDefaults(Notification.DEFAULT_ALL);// 设置使用默认的声音 //cBuilder.setVibrate(new long[]{0, 100, 200, 300});// 设置自定义的振动 cBuilder.setAutoCancel(true); // builder.setSound(Uri.parse("file:///sdcard/click.mp3")); // 设置通知样式为收件箱样式,在通知中心中两指往外拉动,就能出线更多内容,但是很少见 //cBuilder.setNumber(messageList.size()); NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle(); for (String msg : messageList) { inboxStyle.addLine(msg); } inboxStyle.setSummaryText("[" + messageList.size() + "条]" + title); cBuilder.setStyle(inboxStyle); sent(); }