Hank
Hank

Reputation: 3497

Start Activity from Class Loader

For my application's manifest, I included activities from a separate apk file I placed on the sdcard. I was wondering if I can use a ClassLoader to load the activities found in the separate apk files and start them?

EDIT:
So my code would look something like this:

ClassLoader loader = new DexClassLoader("/sdcard/myapp.apk",  getApplicationContext().getFilesDir().getAbsolutePath(), null, AppUI.class.getClassLoader());

Class<?> appClass = loader.loadClass("com.test.myActivity");

Intent myIntent = new Intent(getBaseContext(), appClass);
myIntent.setClassName("com.test", "com.test.myActivity");
startActivity(myIntent);

Upvotes: 1

Views: 1544

Answers (1)

Manfred Moser
Manfred Moser

Reputation: 29912

No. The separate apk will have a different security realm. Look at using intents to start other activities beyond your own application.

Upvotes: 1

Related Questions