Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void showSmallNotification(String title, String message, Intent intent, String url) {
- PendingIntent resultPendingIntent =
- PendingIntent.getActivity(
- mCtx,
- ID_SMALL_NOTIFICATION,
- intent,
- PendingIntent.FLAG_UPDATE_CURRENT
- );
- Uri soundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
- NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(mCtx);
- Notification notification;
- Intent notificationIntent = new Intent(mCtx, DetailActivity.class);
- notificationIntent.putExtra("url", url);
- // notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP |
- // Intent.FLAG_ACTIVITY_SINGLE_TOP);
- notificationIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
- notificationIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- PendingIntent contentIntent = PendingIntent.getActivity(mCtx,
- new Random().nextInt(), notificationIntent,
- PendingIntent.FLAG_UPDATE_CURRENT);
- notification = mBuilder.setSmallIcon(R.mipmap.ic_launcher).setTicker(title).setWhen(0)
- .setAutoCancel(true)
- .setContentIntent(resultPendingIntent)
- .setContentTitle(title)
- .setSmallIcon(R.mipmap.ic_launcher)
- .setStyle(new NotificationCompat.BigTextStyle().bigText(message))
- .setLargeIcon(BitmapFactory.decodeResource(mCtx.getResources(), R.mipmap.ic_launcher))
- .setContentText(message)
- .setSound(soundUri)
- .setContentIntent(contentIntent).setAutoCancel(false)
- .build();
- //notification.flags |= Notification.FLAG_AUTO_CANCEL;
- NotificationManager notificationManager = (NotificationManager) mCtx.getSystemService(Context.NOTIFICATION_SERVICE);
- notificationManager.notify(ID_SMALL_NOTIFICATION, notification);
- }
Advertisement
Add Comment
Please, Sign In to add comment