我已经在手机(银河S6)中启用了辅助功能,然后在单击按钮后尝试进行录音。该按钮具有带有长消息的contentDescription属性。问题是在语音消息录制过程中,“对讲”会继续提供指示。我尝试通过清空contentDescription或使用setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO)来停止音频录制,但是他们都没有暂停对讲语音。有什么停止服用的方法吗?

最佳答案

我不确定这是否是一个好的解决方案,但对我有用:

public boolean onTouch(View v, MotionEvent event) {
            int action = event.getAction();// & MotionEvent.ACTION_MASK;
            if (action == MotionEvent.ACTION_DOWN) {
                mChatAudioLabel.setText(getString(R.string.To_cancel_swipe_and_release));
                AccessibilityManager manager = (AccessibilityManager) getSystemService(ACCESSIBILITY_SERVICE);
                boolean isAccessibilityEnabled = manager.isEnabled();
                if (isAccessibilityEnabled) {
                    AccessibilityEvent accessibilityEvent = AccessibilityEvent.obtain();
                    accessibilityEvent.setEventType(AccessibilityEvent.TYPE_ANNOUNCEMENT);
                    accessibilityEvent.setClassName(getClass().getName());
                    accessibilityEvent.getText().add("\u00A0");
                    manager.sendAccessibilityEvent(accessibilityEvent);
                }


我希望它对其他人有用

07-27 16:24