I'm trying to create a notification, without using the NotificationCompat.Builder
. The motivation is not using the Support Library if its not really needed (and also for educational purposes)
I assume that its possible, as there are "native" Notification
and NotificationManager
classes that are exposed to the users.
My try goes as follow:
Intent i = new Intent();
i.setClassName("com.test", "com.test.SomeActivity");
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK );
PendingIntent pi = PendingIntent.getService(this, 0, i, 0);
notification.setLatestEventInfo(this, title, content,pi);
NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
notificationManager.notify(0 , notification);
This code just run, but no notification appears, and notificationManager.notify()
in general returns void
.