custom class loader for android?

六月ゝ 毕业季﹏ 提交于 2019-12-03 03:37:35

There is a project called droidbox to detect android malware. There is a code that can help you a lot.

package com.loader;

import dalvik.system.DexClassLoader;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;

public class LoaderActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        DexClassLoader dLoader = new DexClassLoader("/sdcard/DroidBoxTests.apk","/sdcard/", null, ClassLoader.getSystemClassLoader().getParent());

        Class calledClass = null;
        try {
            calledClass = dLoader.loadClass("droidbox.tests.DroidBoxTests");
        } catch (ClassNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        Intent it=new Intent(this, calledClass);
        it.setClassName("droidbox.tests", "droidbox.tests.DroidBoxTests");
        startActivity(it);
    }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!