It appears that the current version of TalkBack is ignoring ads if AccessibilityEvent.getSource () returns null, so Toast is better. This has the added benefit of providing continuous feedback to users, regardless of whether they use TalkBack.
Toast.makeText(context, , Toast.LENGTH_SHORT).show();
Typically, you can manually create an AccessibilityEvent and send it through the AccessibilityManager.
AccessibilityManager manager = (AccessibilityManager) context .getSystemService(Context.ACCESSIBILITY_SERVICE); if (manager.isEnabled()) { AccessibilityEvent e = AccessibilityEvent.obtain(); e.setEventType(AccessibilityEvent.TYPE_ANNOUNCEMENT); e.setClassName(getClass().getName()); e.setPackageName(context.getPackageName()); e.getText().add("some text"); manager.sendAccessibilityEvent(e); }
source share