Facebook messenger可访问性

sok*_*kie 11 android accessibility facebook-messenger android-a11y

我正在编写一个辅助功能应用程序,它可以帮助用户使用语音控件和通过外部辅助工具提供的控件来浏览Android.它使用MonkeyTalk Java API来完成更重的工作.
为了帮助用户了解正在发生的事情,我们还使用了辅助功能服务,该服务会读取通知,以便用户可以更快地采取措施.

我被告知,当消息到达facebook messenger时,他们没有得到音频提示,并且检查日志我看到的是:

D/NotificationService(2665): package com.facebook.orcaText: []
Run Code Online (Sandbox Code Playgroud)

event.getText().size()返回0(在AccessibilityEvent事件上).
现在他们必须打开应用程序并将文本读取给他们,这是2个语音命令更多...
我正确地得到所有其他通知.我试着从facebook上寻找关于他们对可访问性的立场的文档,但我一无所获.
有没有办法从他们的通知中获取文本?

Vik*_*ram 2

您可以尝试一下,看看它是否适用于 Facebook Messenger 通知。即使这确实有效,我建议您等待更好的解决方案。

从 API 19 及更高版本开始,Notification对象进行绑定-首次创建时extras传递到的输入。因此,可以使用 形式的键从中提取诸如、等信息。密钥可以在这里找到:链接Notification.BuilderNotificationtitlecontextsummaryBundleNotification.EXTRAS_XXXX

在重写onAccessibilityEvent(AccessibilityEvent event)方法中:

@Override
public void onAccessibilityEvent(AccessibilityEvent event) {
    Parcelable data = event.getParcelableData();

    if (data != null && data instanceof Notification) {
        Log.i("", "We have a notification to parse");

        Notification notification = (Notification) data;

        // For API 19 and above, `Notifications` carry an `extras` bundle with them
        // From this bundle, you can extract info such as:

        //      `EXTRA_TITLE`     -  as supplied to setContentTitle(CharSequence)
        //      `EXTRA_TEXT `     -  as supplied to setContentText(CharSequence)
        //      `EXTRA_INFO_TEXT` -  as supplied to setContentInfo(CharSequence)
        //      ... more at: http://developer.android.com/reference/android/app/Notification.html

        Bundle b = noti.extras;
        Log.i("Notification", "Title: " + b.get(Notification.EXTRA_TITLE));
        Log.i("Notification", "Text: " + b.get(Notification.EXTRA_TEXT));
        Log.i("Notification", "Info Text: " + b.get(Notification.EXTRA_INFO_TEXT));

        /////////////////////////////////////////////////////////////////

        // For API 18 and under:

        // Pass `notification` to a method that parses a Notification object - See link below

        List<String> notificationText = extractTextFromNotification(notification);
        ....
        ....
    }
}
Run Code Online (Sandbox Code Playgroud)

extractTextFromNotification(Notification)可以是这里的一种方法:Link。不用说,这是一种解决方法,并且需要进行大量测试才能确保其按要求工作。