从RemoteViews对象检索文本 [英] Retrieve text from a RemoteViews Object

查看:99
本文介绍了从RemoteViews对象检索文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆