Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void generateNotification(Context context, String title, JSONObject json) {
- Intent intent = new Intent(context, NewsActivity.class);
- PendingIntent contentIntent = PendingIntent.getActivity(context, 0, intent, 0);
- numMessages = 0;
- NotificationManager mNotifM = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
- NotificationCompat.Builder mBuilder =
- new NotificationCompat.Builder(context)
- .setSmallIcon(R.drawable.ic_launcher)
- .setContentTitle(title)
- .setContentText("New Post in the Blog")
- .setNumber(++numMessages);
- mBuilder.setContentIntent(contentIntent);
- mNotifM.notify(NOTIFICATION_ID, mBuilder.build());
- try {
- NotificationManager notificationManager = (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
- notificationManager.cancel(NOTIFICATION_ID);
- }
- catch (Exception e) {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement