Advertisement
Guest User

Untitled

a guest
Nov 17th, 2019
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.30 KB | None | 0 0
  1. //call notifiacation    
  2.     NotificationManagerCompat.from(MainActivity.this).notify(NotificationManager.NOTIFY_ID, new NotificationManager().getBuilder(this,"Hyieohered").build());
  3.  
  4. //NOTIFICATION MANAGER
  5. public class NotificationManager {
  6.     public  static final int  NOTIFY_ID= 187;
  7.  
  8.     public NotificationCompat.Builder getBuilder(Context c, String qName) {
  9.         Intent intent = new Intent(c, AddInQ.class);
  10.         Intent yesI = new Intent(c, AgreeWithQ.class);
  11.         Intent noI = new Intent(c, DisagreeWithQ.class);
  12.         PendingIntent cIntent = PendingIntent.getActivity(c,0,intent,PendingIntent.FLAG_CANCEL_CURRENT);
  13.         PendingIntent yesActivity = PendingIntent.getActivity(c, 0, yesI, PendingIntent.FLAG_CANCEL_CURRENT);
  14.         PendingIntent noActivity = PendingIntent.getActivity(c, 0, noI, PendingIntent.FLAG_CANCEL_CURRENT);
  15.         return new NotificationCompat.Builder(c,"simple channel").setSmallIcon(R.drawable.ic_check_q)
  16.                 .setContentTitle("Add in querry").setContentText("R u wanna add in "+qName)
  17.                 .setPriority(NotificationCompat.PRIORITY_DEFAULT).setContentIntent(cIntent)
  18.                 .addAction(R.drawable.ic_yes,"yes",yesActivity)
  19.                 .addAction(R.drawable.ic_no,"no",noActivity)
  20.                 .setAutoCancel(true);
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement