gpt4 book ai didi

android - 为什么 *.so 文件加载为静态代码?

转载 作者:行者123 更新时间:2023-11-29 18:25:28 33 4
gpt4 key购买 nike

我使用的是opencv4android,如下图。我读过的大部分教程都指出*.so文件应该放在静态代码块中。为什么不使用单例模式,只在使用时加载?

 static{
System.loadLibrary("opencv_java3")
}

最佳答案

official Android documentation about JNI他们说:

If you have only one class with native methods, it makes sense for the call to System.loadLibrary to be in a static initializer for that class. Otherwise you might want to make the call from Application so you know that the library is always loaded, and always loaded early.

你也可以看看this SO answer .

关于android - 为什么 *.so 文件加载为静态代码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59250664/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com