Well, I'm trying to use notifications, but this code doesn't work. I've tested it on 4.4 and 5.0. I can't understand, what is wrong.
public void onClick(View view) { Context context = getApplicationContext(); Intent notificationIntent = new Intent(context, MainActivity.class); PendingIntent contentIntent = PendingIntent.getActivity(context, 0,notificationIntent, PendingIntent.FLAG_CANCEL_CURRENT); Resources res = context.getResources(); Notification.Builder builder = new Notification.Builder(context); builder.setContentIntent(contentIntent) .setWhen(System.currentTimeMillis()) .setAutoCancel(true) .setContentTitle("Title") .setContentText("Text"); Notification notification = builder.build(); NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.notify(NOTIFY_ID, notification); } I'll be grateful for answer.