public static void showNotification( Context context, Updater.PackageInfo[] infosRom, Updater.PackageInfo[] infosGapps) { Resources resources = context.getResources(); if (infosRom != null) { sPackageInfosRom = infosRom; } else { infosRom = sPackageInfosRom; } if (infosGapps != null) { sPackageInfosGapps = infosGapps; } else { infosGapps = sPackageInfosGapps; } int contentTitleResourceId = -1; if (infosRom.length > 0 && infosGapps.length > 0) { contentTitleResourceId = !Utils.weAreInBS() ? R.string.update_all_to_bs : R.string.new_all_found_title; } else if (infosRom.length == 0) { contentTitleResourceId = !Utils.weAreInBS() ? R.string.update_gapps_to_bs : R.string.new_gapps_found_title; } else { contentTitleResourceId = !Utils.weAreInBS() ? R.string.update_rom_to_bs : R.string.new_rom_found_title; } Intent intent = new Intent(context, MainActivity.class); NotificationInfo fileInfo = new NotificationInfo(); fileInfo.mNotificationId = Updater.NOTIFICATION_ID; fileInfo.mPackageInfosRom = infosRom; fileInfo.mPackageInfosGapps = infosGapps; intent.putExtra(FILES_INFO, fileInfo); PendingIntent pIntent = PendingIntent.getActivity( context, Updater.NOTIFICATION_ID, intent, PendingIntent.FLAG_UPDATE_CURRENT); NotificationCompat.Builder builder = new NotificationCompat.Builder(context) .setContentTitle(resources.getString(contentTitleResourceId)) .setSmallIcon(R.drawable.ic_launcher) .setContentIntent(pIntent); String contextText = ""; if (infosRom.length + infosGapps.length == 1) { String filename = infosRom.length == 1 ? infosRom[0].getFilename() : infosGapps[0].getFilename(); contextText = resources.getString(R.string.new_package_name, new Object[] {filename}); } else { contextText = resources.getString( R.string.new_packages, new Object[] {infosRom.length + infosGapps.length}); } builder.setContentText(contextText); NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle(); inboxStyle.setBigContentTitle(context.getResources().getString(contentTitleResourceId)); if (infosRom.length + infosGapps.length > 1) { inboxStyle.addLine(contextText); } for (int i = 0; i < infosRom.length; i++) { inboxStyle.addLine(infosRom[i].getFilename()); } for (int i = 0; i < infosGapps.length; i++) { inboxStyle.addLine(infosGapps[i].getFilename()); } builder.setStyle(inboxStyle); Notification notif = builder.build(); NotificationManager notificationManager = (NotificationManager) context.getSystemService(Service.NOTIFICATION_SERVICE); notif.flags |= Notification.FLAG_AUTO_CANCEL; notificationManager.notify(Updater.NOTIFICATION_ID, notif); }