1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
NotificationCompat.Builder builder =
new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_launcher)
.setContentTitle("Notifications")
.setContentText("Exemple notification");
Intent notificationIntent = new Intent(this, CreateNotificationActivity.class);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent,
PendingIntent.FLAG_UPDATE_CURRENT);
builder.setContentIntent(contentIntent);
NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
manager.notify(1, builder.build());
} catch (Exception ex) { // vu que toutes les exceptions sont gérées pareil...
Log.e("Service", "Erreur notification : ", ex);
} |
Partager