3

is there anyway to load a class from differen application ?

for example, I have two application and one of them has SomeExample class file. and I want to load it and use from another application.

I try to use, Class.forName. but this function throws "ClassNotFoundExpetion".

Adem
  • 9,402
  • 9
  • 43
  • 58

2 Answers2

4

Is there anyway to load a class from differen application ?

No, sorry.

You can use startActivity(), startService(), and so on to launch components of another application, but each application's code remains separate.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • In some cases, it seems to be possible (the target APK would have to be world-readable) - see my answer and the reference. It's almost certainly not a good idea, though. – lxgr Dec 07 '12 at 09:39
1

While in most cases unadvisable (Android has many APIs to solve the common problems of inter-app communication without sharing code), it's possible by using PathClassLoader.

See also Android- Using DexClassLoader to load apk file.

Community
  • 1
  • 1
lxgr
  • 3,719
  • 7
  • 31
  • 46