List of usage examples for android.app PendingIntent getActivities
public static PendingIntent getActivities(Context context, int requestCode, @NonNull Intent[] intents, @Flags int flags)
From source file:org.huxizhijian.hhcomicviewer.utils.NotificationUtil.java
/** * //w w w . ja va 2 s . com * * @param comicChapter */ public void showNotification(DownloadManagerService service, ComicChapter comicChapter) { NotificationCompat.Builder builder = new NotificationCompat.Builder(mContext); // builder.setSmallIcon(android.R.drawable.stat_sys_download).setLargeIcon(mBitmap).setAutoCancel(false) .setOngoing(true).setCategory(NotificationCompat.CATEGORY_PROGRESS); builder.setTicker(comicChapter.getChapterName() + " "); //? CharSequence contentTitle = comicChapter.getChapterName() + " - "; // ? CharSequence contentText = 0 + "/" + comicChapter.getPageCount(); // ? //? Intent intent0 = new Intent(mContext, MainActivity.class); //??? Intent intent1 = new Intent(mContext, DownloadingChapterActivity.class); //? Intent[] intents = { intent0, intent1 }; //?PendingIntent PendingIntent contentIntent = PendingIntent.getActivities(mContext, 0, intents, 0); // builder.setContentTitle(contentTitle).setContentText(contentText).setContentIntent(contentIntent); builder.setProgress(comicChapter.getPageCount(), 0, true); //false?true? Notification notification = builder.build(); //?service?? service.startForeground(comicChapter.getId(), notification); }
From source file:org.huxizhijian.hhcomicviewer.utils.NotificationUtil.java
/** * //from w w w . j a v a2 s . c o m * * @param comicChapter */ public void finishedNotification(ComicChapter comicChapter) { NotificationCompat.Builder builder = new NotificationCompat.Builder(mContext); //?? builder.setSmallIcon(android.R.drawable.stat_sys_download_done).setLargeIcon(mBitmap) .setTicker(comicChapter.getChapterName() + " ").setOngoing(false).setAutoCancel(true); //? CharSequence contentTitle = comicChapter.getComicTitle(); // ? CharSequence contentText = comicChapter.getChapterName() + " - "; // ? //? Intent intent0 = new Intent(mContext, MainActivity.class); //??? Intent intent1 = new Intent(mContext, OfflineComicDownloadActivity.class); //? Intent[] intents = { intent0, intent1 }; //?PendingIntent PendingIntent contentIntent = PendingIntent.getActivities(mContext, 0, intents, 0); // builder.setContentTitle(contentTitle).setContentText(contentText).setContentIntent(contentIntent); //?? builder.setAutoCancel(true); Notification notification = builder.build(); //? sNotificationManager.notify(Constants.FINISHED_NOTIFICATION_ID, notification); }
From source file:com.piggate.sdk.Piggate.java
public void postNotification(String title, String msg, Class myClass, int resource, Bundle extras, Boolean force) {//from w w w.ja v a 2 s . c om if (!getApplicationContext().getPackageName() .equalsIgnoreCase(((ActivityManager) getApplicationContext() .getSystemService(getApplicationContext().ACTIVITY_SERVICE)).getRunningAppProcesses() .get(0).processName) || force) { Intent notifyIntent = new Intent(_context, myClass); if (extras != null) notifyIntent.putExtras(extras); notifyIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent pendingIntent = PendingIntent.getActivities(_context, 0, new Intent[] { notifyIntent }, PendingIntent.FLAG_UPDATE_CURRENT); Notification notification = new Notification.Builder(_context).setSmallIcon(resource) .setContentTitle(title).setContentText(msg).setAutoCancel(true).setContentIntent(pendingIntent) .build(); notification.defaults |= Notification.DEFAULT_SOUND; notification.defaults |= Notification.DEFAULT_LIGHTS; notificationManager.notify(123, notification); } }
From source file:org.huxizhijian.hhcomicviewer.utils.NotificationUtil.java
/** * ?//from w w w.java 2s . c o m */ public void updateNotification(int id, ComicChapter comicChapter) { /*//?? int progress = (int) ((float) downloadPosition / (float) pageCount * 100f); notification.contentView.setProgressBar(R.id.progress_bar_notification, 100, progress, false); // notification.contentView.setTextViewText(R.id.textView_notification_progress, downloadPosition + "/" + pageCount);*/ NotificationCompat.Builder builder = new NotificationCompat.Builder(mContext); // builder.setSmallIcon(android.R.drawable.stat_sys_download).setLargeIcon(mBitmap).setAutoCancel(false) .setOngoing(true).setCategory(NotificationCompat.CATEGORY_PROGRESS); builder.setTicker(comicChapter.getChapterName() + " "); //? CharSequence contentTitle = comicChapter.getChapterName() + " - "; // ? CharSequence contentText = comicChapter.getDownloadPosition() + "/" + comicChapter.getPageCount(); // ? //? Intent intent0 = new Intent(mContext, MainActivity.class); //??? Intent intent1 = new Intent(mContext, DownloadingChapterActivity.class); //? Intent[] intents = { intent0, intent1 }; //?PendingIntent PendingIntent contentIntent = PendingIntent.getActivities(mContext, 0, intents, 0); // builder.setContentTitle(contentTitle).setContentText(contentText).setContentIntent(contentIntent); builder.setProgress(comicChapter.getPageCount(), comicChapter.getDownloadPosition(), false); //false? Notification notification = builder.build(); // sNotificationManager.notify(id, notification); }