Note that there are some explanatory texts on larger screens.

plurals
  1. POExtract notification text from parcelable, contentView or contentIntent
    text
    copied!<p>So I got my AccessibilityService working with the following code: </p> <pre><code>@Override public void onAccessibilityEvent(AccessibilityEvent event) { if (event.getEventType() == AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED) { List&lt;CharSequence&gt; notificationList = event.getText(); for (int i = 0; i &lt; notificationList.size(); i++) { Toast.makeText(this.getApplicationContext(), notificationList.get(i), 1).show(); } } } </code></pre> <p>It works fine for reading out the text displayed when the notifcation was created <strong>(1)</strong>.</p> <p><img src="https://i.stack.imgur.com/VD51D.png" alt="enter image description here"></p> <p>The only problem is, I also need the value of <strong>(3)</strong> which is displayed when the user opens the notification bar. <strong>(2)</strong> is not important for me, but it would be nice to know how to read it out. As you probably know, all values can be different.</p> <p><img src="https://i.stack.imgur.com/5sfoK.png" alt="enter image description here"></p> <p>So, how can I read out <strong>(3)</strong>? I doubt this is impossible, but my <code>notificationList</code> seems to have only one entry (at least only one toast is shown).</p> <p>Thanks a lot!</p> <p><strong>/edit:</strong> I could extract the notification parcel with</p> <pre><code>if (!(parcel instanceof Notification)) { return; } final Notification notification = (Notification) parcel; </code></pre> <p>However, I have no idea how to extract the notifcation's message either from <code>notification</code> or <code>notification.contentView</code> / <code>notification.contentIntent</code>.</p> <p>Any ideas?</p> <p><strong>/edit: To clarify what is asked here:</strong> How can I read out <strong>(3)</strong>?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload