启用TalkBack时,有没有办法将辅助功能焦点手动设置为特定视图?例如,当我的Activity启动时,我希望TalkBack自动关注某个Button(视图周围的黄色框)并阅读其内容描述.
到目前为止我尝试过的:
myButton.setFocusable(true);
myButton.setFocusableInTouchMode(true);
myButton.requestFocus();
Run Code Online (Sandbox Code Playgroud)
requestFocus()似乎只是请求输入焦点而与可访问性焦点无关.我也尝试过:
myButton.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED);
myButton.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_FOCUSED);
myButton.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_TEXT_CHANGED);
myButton.announceForAccessibility("accessibility test");
myButton.performAccessibilityAction(64, null); // Equivalent to ACTION_ACCESSIBILITY_FOCUS
AccessibilityManager manager = (AccessibilityManager) getSystemService(Context.ACCESSIBILITY_SERVICE);
if (manager.isEnabled()) {
AccessibilityEvent e = AccessibilityEvent.obtain();
e.setSource(myButton);
e.setEventType(AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED);
e.setClassName(getClass().getName());
e.setPackageName(getPackageName());
e.getText().add("another accessibility test");
manager.sendAccessibilityEvent(e);
}
Run Code Online (Sandbox Code Playgroud)
这似乎都不起作用.
我在Android Studio中制作了一个使用两个库的应用程序.一个带有Android包装器和jar库的本机库.出于某种原因,如果将其他jar库编译到项目中,则不会加载本机库.因此,如果我只使用本机库运行应用程序,一切正常.我将另一个jar库添加到我的gradle文件并繁荣...一个UnsatisfiedLinkError:
java.lang.UnsatisfiedLinkError: Couldn't load MobileOcrEngine from loader dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.example.app-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.app-1, /vendor/lib, /system/lib]]]: findLibrary returned null
Run Code Online (Sandbox Code Playgroud)
我用这个时我的应用运行正常:
dependencies {
compile fileTree(include: ['*.jar'], dir: 'src/main/jniLibs')
compile 'com.android.support:support-v13:21.0.2'
compile project(':wheel')
}
Run Code Online (Sandbox Code Playgroud)
我尝试时发生错误:
dependencies {
compile fileTree(include: ['*.jar'], dir: 'src/main/jniLibs')
compile 'com.android.support:support-v13:21.0.2'
compile project(':wheel')
compile files('libs/realm-0.78.0.jar')
}
Run Code Online (Sandbox Code Playgroud)
或者当我尝试使用相同的库但使用Maven存储库时:
dependencies {
compile fileTree(include: ['*.jar'], dir: 'src/main/jniLibs')
compile 'com.android.support:support-v13:21.0.2'
compile project(':wheel')
compile 'io.realm:realm-android:0.78.0'
}
Run Code Online (Sandbox Code Playgroud)
或者如果我尝试将jar放在jniLibs文件夹中:
dependencies {
compile fileTree(include: ['*.jar'], dir: 'src/main/jniLibs')
compile 'com.android.support:support-v13:21.0.2'
compile project(':wheel')
}
Run Code Online (Sandbox Code Playgroud)
我不知道问题的根源在哪里.有两个库中的一个,Android Studio还是我做错了什么?
注意: 我知道StackOverflow上有很多关于UnsatisfiedLinkErrors的问题,但这些都没有为我的问题提供解决方案.如果它是我使用的唯一库,我加载本机库没有问题...