【问题标题】:How to know is there user added libraries into the project programmatically?如何知道用户是否以编程方式将库添加到项目中?
【发布时间】:2017-04-14 13:24:40
【问题描述】:

在我的项目中,我包含了用户创建的库。我想检查项目中是否存在库。 我该怎么做?

【问题讨论】:

  • 用户创建的库是什么意思?

标签: android android-library


【解决方案1】:

以下代码可能会有所帮助

   public static void checkLibrary(){
                try {
                    Log.e(" i am in","checklibrary");
                    Set<String> libs = new HashSet<String>();
                    String mapsFile = "/proc/" + android.os.Process.myPid() + "/maps";
                    BufferedReader reader = new BufferedReader(new FileReader(mapsFile));
                    String line;
                    while ((line = reader.readLine()) != null) {
                        if (line.endsWith(".so")) {
                            int n = line.lastIndexOf(" ");
                            libs.add(line.substring(n + 1));
                        }
                    }
                    Log.e("Ldd", libs.size() + " libraries:");
                    for (String lib : libs) {
                        Log.e("Ldd", lib);
                    }
                } catch (FileNotFoundException e) {
                    // Do some error handling...
                } catch (IOException e) {
                    // Do some error handling...
                }
            }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-04
    • 1970-01-01
    相关资源
    最近更新 更多