tegarkurniawan

Notification

May 18th, 2016
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1. Bundle bundle=new Bundle();
  2. if(major == 48180 && minor == 14092 || major == 54602 && minor == 59234){
  3.  
  4. bundle.putInt("image", R.drawable.oeang);
  5. }else if(major == 35798 && minor == 37801 || major == 21136 && minor == 51831){
  6. bundle.putInt("image", R.drawable.monas);
  7. }else{
  8.  
  9. bundle.putInt("image", R.drawable.soekarno);
  10. }
  11.  
  12. Intent notificationIntent = new Intent(this, DetailNotification.class);
  13. notificationIntent.putExtra("major",major);
  14. notificationIntent.putExtra("minor",minor);
  15. notificationIntent.putExtra("title", title);
  16. notificationIntent.putExtra("message",message);
  17.  
  18.  
  19. notificationIntent.putExtras(bundle);
  20. PendingIntent pendingIntent = PendingIntent.getActivity(this, 0,
  21. notificationIntent, Intent.FLAG_ACTIVITY_NEW_TASK);
  22.  
  23. Bitmap bitmap_image = BitmapFactory.decodeResource(this.getResources(), R.drawable.big_picture);
  24.  
  25. Notification notification = new Notification.Builder(this)
  26. .setSmallIcon(android.R.drawable.ic_dialog_info)
  27. .setContentTitle(title)
  28. .setContentText(message)
  29. .setAutoCancel(true)
  30. .setContentIntent(pendingIntent)
  31. .setStyle(new Notification.BigPictureStyle()
  32. .bigPicture(bitmap_image))
  33. .build();
  34. notification.defaults |= Notification.DEFAULT_SOUND;
  35. NotificationManager notificationManager =
  36. (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
  37. notificationManager.notify(2, notification);
Advertisement
Add Comment
Please, Sign In to add comment