我打了一下牆。任何幫助,將不勝感激。我有一個應用程序,我想使用DexClassLoader加載另一個apk文件。Android-使用DexClassLoader加載apk文件
這裏是我的代碼:
DexClassLoader dLoader = new DexClassLoader("/sdcard/download/test.apk","/sdcard/download",null,ClassLoader.getSystemClassLoader().getParent());
Class calledClass = dLoader.loadClass("com.test.classname");
Intent it=new Intent(this, calledClass);
it.setClassName("com.test", "com.test.classname");
startActivity(it);
現在我已經安裝了test.apk所以,當我跑在上面的代碼 工作的罰款和啓動的應用程序。不過,我希望能夠在未安裝test.apk的情況下運行此操作(因爲 會打敗應用程序的整個點)。所以我卸載它, 當我跑我的應用程序,我再次得到這個錯誤:
android.content.ActivityNotFoundException: Unable to find explicit
activity class {com.test/com.test.classname}; have you declared this
activity in your AndroidManifest.xml.
所以我有點難倒這裏。此活動在我試圖運行的apk的Manifest 中聲明。我無法在我的應用程序 Manifest中聲明它。有任何想法嗎?
謝謝, 克雷格