I need to retrieve some text from a RemoteViews
object. It is possible for me to get the LayoutId, but I have no idea how to retrieve text from a TextView
that is in this RemoteView
(namely a notification).
Also the RemoteView
only contains setters, but no getters, so I guess I have to use the LayoutId (somehow).
Can you help me with that? Thanks!
/edit: The reason why I am asking this, is because I have an AccessibilityService
that retrieves the notification. Therefore this is the only way of retrieving the value.
/edit2: I use this code for receiving the notification:
@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();
}
if (!(parcel instanceof Notification)) {
return;
}
final Notification notification = (Notification) parcel;
doMoreStuff();
}
}
With the notification
object I have access to a RemoteViews
(notification.contentView
) and to a PendingIntent
(notification.contentIntent
).
To get the layoutId, I can call contentView.getLayoutId()
SharedPreferences
, etc), and then have both theRemoteViews
and your other code access the information from there. – PosthorseAccessibilityService
for retrieving the notification, so I cannot simply store the value somewhere, because my application did not create the notification ;-) – Apennines