So I got my AccessibilityService working with the following code:
@Override
public void onAccessibilityEvent(AccessibilityEvent event) {
if (event.getEventType() == AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED) {
List<CharSequence> notificationList = event.getText();
for (int i = 0; i < notificationList.size(); i++) {
Toast.makeText(this.getApplicationContext(), notificationList.get(i), 1).show();
}
}
}
It works fine for reading out the text displayed when the notifcation was created (1).
The only problem is, I also need the value of (3) which is displayed when the user opens the notification bar. (2) 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.
So, how can I read out (3)? I doubt this is impossible, but my notificationList
seems to have only one entry (at least only one toast is shown).
Thanks a lot!
/edit: I could extract the notification parcel with
if (!(parcel instanceof Notification)) {
return;
}
final Notification notification = (Notification) parcel;
However, I have no idea how to extract the notifcation's message either from notification
or notification.contentView
/ notification.contentIntent
.
Any ideas?
/edit: To clarify what is asked here: How can I read out (3)?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…