2012-09-12 45 views

回答

3

因此,對於Android,我們可以使用DexFile類來枚舉給定APK中的可見類。

 try { 
      DexFile dexFile = new DexFile(new File("/data/app/com.uxpsystems.cepclient-2.apk")); 
      Enumeration<String> enumeration = dexFile.entries(); 

      if (enumeration.hasMoreElements() == false){ 
       Logger.d(LOG_TAG, "--> Enumeration has no elements"); 
      } 

      while (enumeration.hasMoreElements()){ 
       String className = enumeration.nextElement(); 

       if (className.substring(0, 18).equals("com.somecompany.aproduct")){ 
        Logger.d(LOG_TAG, "--> Enumeration: " + className); 
       }else{ 
//     Logger.d(LOG_TAG, "--> Failed match: " + className.substring(0, 18)); 
       } 
      } 
     } catch (IOException e) { 
      e.printStackTrace(); 
     } 
    } 
+0

感謝您的分享 – Diljeet