从RemoteViews对象检索文本 [英] Retrieve text from a RemoteViews Object
问题描述
我需要从RemoteViews
对象中检索一些文本.我可以获取LayoutId,但是我不知道如何从RemoteView
中的TextView
检索文本(即通知).
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).
RemoteView
还仅包含setter,但没有getter,所以我想我必须使用LayoutId(以某种方式).
Also the RemoteView
only contains setters, but no getters, so I guess I have to use the LayoutId (somehow).
您能帮我吗?谢谢!
/edit:之所以这样问,是因为我有一个AccessibilityService
可以检索通知.因此,这是获取值的唯一方法.
/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 :我使用以下代码接收通知:
/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();
}
}
使用notification
对象,我可以访问RemoteViews
(notification.contentView
)和PendingIntent
(notification.contentIntent
).
要获取layoutId,我可以致电contentView.getLayoutId()
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()
推荐答案
来自
这篇关于从RemoteViews对象检索文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!