Advertisement
Guest User

s

a guest
Jan 30th, 2015
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.07 KB | None | 0 0
  1. private void generateNotification(Context context, String title, JSONObject json) {
  2.         Intent intent = new Intent(context, NewsActivity.class);
  3.         PendingIntent contentIntent = PendingIntent.getActivity(context, 0, intent, 0);
  4.         numMessages = 0;
  5.         NotificationManager mNotifM = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
  6.         NotificationCompat.Builder mBuilder =
  7.                 new NotificationCompat.Builder(context)
  8.                         .setSmallIcon(R.drawable.ic_launcher)
  9.                         .setContentTitle(title)
  10.                         .setContentText("New Post in the Blog")
  11.                         .setNumber(++numMessages);
  12.         mBuilder.setContentIntent(contentIntent);
  13.         mNotifM.notify(NOTIFICATION_ID, mBuilder.build());
  14.         try {
  15.             NotificationManager notificationManager = (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
  16.             notificationManager.cancel(NOTIFICATION_ID);
  17.         }
  18.         catch (Exception e) {
  19.  
  20.         }
  21.  
  22.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement