OpenCV的服务意向一定要明确,安卓5.0棒棒糖 [英] OpenCV Service Intent must be explicit, Android 5.0 Lolipop
问题描述
所以我建立这个应用程序为我的大学本科文凭的使用了OpenCV。一切都进行得很顺利,直到我更新了我的手机的Android 5.0。
So I'm building this application for my bachelor's diploma that uses OpenCV. Everything was going fine until I updated my phone's Android to 5.0.
在更新我的项目停止,因为这个工作,
After the update my project stopped working, because of this:
java.lang.IllegalArgumentException:如果服务意向一定要明确:意向{行为= org.opencv.engine.BIND}
java.lang.IllegalArgumentException: Service Intent must be explicit: Intent { act=org.opencv.engine.BIND }
我已阅读并告知我一下有关在Android的5.0隐含意图的新的限制措施,但如何实现这个愿望,以便OpenCV的工作?
I have read and informed myself about the new restrictions regarding implicit intents in Android 5.0, but how can I get around this in order for OpenCV to work?
我可以修改 AsyncServiceHelper.java 在OpenCV的SDK文件,以试图解决这个问题,但我怎么能得到需要OpenCV的服务的类对象来运行,以使用一个明确的意图是什么?
I could modify the AsyncServiceHelper.java file in the OpenCV SDK in order to try and fix this, but how could I get the Class object of the OpenCV service that needs to be run, in order to use an explicit intent?
或者,也许这种做法是死路一条,但是否有任何其他的方法来此,或者是我唯一的选择要么是更新OpenCV的SDK,或者降级的Android版本我的设备上?
Or maybe this approach is a dead end, but are there any other approaches to this, or are my only options either an update to the OpenCV SDK, or to downgrade the Android Version on my device?
在此先感谢!
编辑:发布解决问题的办法。
Posted solution to the question
推荐答案
我觉得改变了android:targetSdkVersion不是很长的解决方案;)所以不是我添加了包名,使意图明确(大概也精美;):
I think changing the android:targetSdkVersion is not a solution for very long ;) So instead I added the package name to make the intent explicit (and probably also exquisite;) :
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;
}
}
也许有人可以告诉这一个OpenCV的comitter,推修补程序。
Maybe someone can tell an opencv comitter about this, to push a hotfix.
编辑:的从以下评论:对于任何人想知道这个功能的位置,它是在src / main /爪哇/组织/ OpenCV的/安卓/ AsyncServiceHelper。 java的
From a comment below: For anyone else wondering the location of this function, it's in src/main/java/org/opencv/android/AsyncServiceHelper.java
这篇关于OpenCV的服务意向一定要明确,安卓5.0棒棒糖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!