问题描述
此问题已被多次询问,仅提出建议.希望能理解每一个建议.
This question has been asked severally and only suggestions are made. Ill comprehend every suggestion hopefully.
依赖在清单中定义
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version"/>
<meta-data
android:name="com.google.android.gms.vision.DEPENDENCIES"
android:value="ocr" />
并在应用级别添加
compile 'com.google.android.gms:play-services-vision:9.8.0'
测试设备有足够的存储空间,大于内部的 10%,并且具有非常好的互联网连接.权限也有明确规定
The test device has sufficient storage which is greater than 10% of the internal and also has a very good internet connection. Permissions are also clearly defined
我们启动 TextRecognizer 来检测文本并得到空响应:
We start the TextRecognizer to detect text and we get our null response:
TextRecognizer textRecognizer = new TextRecognizer.Builder(getContext()).build();
if (!textRecognizer.isOperational()) {
Log.w("Main Activity", "Dependencies are not yet available");
Toast.makeText(getContext(), "Cannot Detect", Toast.LENGTH_LONG).show();
if(((MainActivity) getActivity()).hasLowStorage()) {
Toast.makeText(getContext(), "Low Storage", Toast.LENGTH_LONG).show();
Log.w("Custom_Storage", "Low Storage");
}
}
大多数建议是使用较低的依赖compile 'com.google.android.gms:play-services:7.8+'
但它并不适用于所有人.应用发布后,部分用户无法使用.
Most suggestions are to use a lower dependency compile 'com.google.android.gms:play-services:7.8+'
but it doesn't work for everyone. After publishing the app, some users cant use the app.
这些建议并不能解决问题.
The suggestions are not solving the problem.
类似问题:TextRecognizer isOperational API 总是返回 false 和detector.isOperational() 在 android 上始终为 false
推荐答案
TextRecognizer
API 需要下载一些依赖文件.通常在安装时完成,但有时需要更长的时间.应用程序将自动下载这些文件.等待一段时间下载这些文件.直到下载完成TextRecognizer.isOperational
将返回false
.doanlowd 完成后 TextRecognizer.isOperational
将返回 true
.
TextRecognizer
API is required to download few dependency files. Usually it is done at the time of installation but sometimes it take longer time. App will automatically download those files. Wait some time to download those files. Until download is complete TextRecognizer.isOperational
will return false
. After the doanlowd is completed TextRecognizer.isOperational
will return true
.
这篇关于TextRecognizer.isOperational() API 总是返回 false的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!