Sunday, 29 November 2015

heads up notification

private void showHeadsUpNotification()
{
    final Notification.Builder nb = new Notification.Builder(this);
    nb.setContentTitle("Foobar");
    nb.setContentText("I am the content text");
    nb.setDefaults(Notification.DEFAULT_ALL);
    nb.setOngoing(true);
    nb.setSmallIcon(android.R.drawable.ic_dialog_info);
    nb.setContentIntent(PendingIntent.getActivity(this, 0, getIntent(), 0));

    // Commenting this line 'fixes' it by not making it heads-up, but that's    // not what I want...    nb.setPriority(Notification.PRIORITY_HIGH);

    ((NotificationManager) getSystemService(NOTIFICATION_SERVICE)).notify(0, nb.build());
}

No comments:

Post a Comment