Search code examples
androidnotificationsandroid-notificationstalkback

Android notification not announced by TalkBack


My Android app creates a notification. The notification is correctly displayed. However, TalkBack does not announce the notification, as it does, for example, when I receive new email. If I display all the notifications and scroll through them, TalkBack will read the text of my notification. However, I want it to automatically announce the notification when it is raised.

String notificationText = getResources().getString(R.string.notifyText);
String notificationTitle = getResources().getString(R.string.notifyTitle);

NotificationCompat.Builder notificationBuilder =
    new NotificationCompat.Builder(this)
        .setSmallIcon(R.drawable.ic_notification)
        .setContentTitle(notificationTitle)
        .setContentText(notificationText)
    .setPriority(NotificationCompat.PRIORITY_MAX);

NotificationManager notificationManager =
    (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(NOTIFICATION_ID, notificationBuilder.build());

Solution

  • I found the answer to my question.

    Of the various methods of NotificationCompat.Builder, setContentText() determines what is displayed visually, but setTicker() is the method that determines what, if anything, is read by TalkBack.