Skip to content

Load an APK file and use reflection to execute a method

Notifications You must be signed in to change notification settings

franzejr/APKLoader

Repository files navigation

APKLoader

Load an APK file and use reflection to execute a method

Usage

Loading an APK:

//Class you wan to load
className = "com.ufc.methods.Sum";
		
//Apk Name
String appName = "StaticMath.apk";

String pathExternalStorage = Environment.getExternalStorageDirectory().toString();
appDirectory =  new File(pathExternalStorage +"/" + appName);
	
staticMathApk = (APKLoader) APKLoader.newInstance(appDirectory,
				getCacheDir().getAbsolutePath(), getClassLoader());

Executing a method:

sumClass = staticMathApk.loadClass(className);
ClassLoaderWrapper classLoader = new ClassLoaderWrapper(sumClass);
//hashMap contains the parameters from my Method

//Getting the result
result = (String) classLoader.executeMethod("execute", hashMap);

About

Load an APK file and use reflection to execute a method

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages