geo*_*gej 17 android opencv android-intent opencv4android
我正在为使用OpenCV的学士学位文凭构建此应用程序.一切都很顺利,直到我将手机的Android更新到5.0.
更新后,我的项目停止工作,因为:
java.lang.IllegalArgumentException:Service Intent必须是显式的:Intent {act = org.opencv.engine.BIND}
我已阅读并告知自己有关Android 5.0中隐式意图的新限制,但我如何解决这个问题以使OpenCV工作?
我可以修改OpenCV SDK中的 AsyncServiceHelper.java文件以尝试修复此问题,但是为了使用显式意图,我怎样才能获得需要运行的OpenCV服务的Class对象?
或者这种方法可能是死路一条,但有没有其他方法,或者我唯一的选择是更新OpenCV SDK,还是降级我的设备上的Android版本?
Sim*_*mon 49
我认为更改android:targetSdkVersion不是很长时间的解决方案;)所以我添加了包名称以使intent明确:
public static boolean initOpenCV(String Version, final Context AppContext,
final LoaderCallbackInterface Callback) {
AsyncServiceHelper helper = new AsyncServiceHelper(Version, AppContext,
Callback);
Intent intent = new Intent("org.opencv.engine.BIND");
intent.setPackage("org.opencv.engine");
if (AppContext.bindService(intent, helper.mServiceConnection,
Context.BIND_AUTO_CREATE)) {
return true;
} else {
AppContext.unbindService(helper.mServiceConnection);
InstallService(AppContext, Callback);
return false;
}
}
Run Code Online (Sandbox Code Playgroud)
也许有人可以告诉opencv comitter这个,推动修补程序.
编辑:从下面的评论:对于其他任何想知道这个函数的位置的人,它在src/main/java/org/opencv/android/AsyncServiceHelper.java中
我在工作时看到了答案,对其进行了测试并解决了问题.显然它同时被删除了.再次发布以供参考
解决方案正在改变:AndroidManifest.xml中的android:targetSdkVersion从21到19.不敢相信这很容易,我失去了一天想弄明白,买嘿,再次感谢发布初步答案的人:)
谢谢stackoverflow!
归档时间: |
|
查看次数: |
11513 次 |
最近记录: |