Hello everyone,
meanwhile I can answer the thread concerning reflection on classes in
other packages myself.
The approach with Context.createPackageContext("packagename")
eventually was successful - What was missing is to set the appropriate
permissions:
-------- Code snippet --------
//ask for the code of the foreign context to be included and to ignore
any security given by the cross-process(owner) execution
//in working-environment to error checking ...
Context tmpCtxt = createPackageContext("com.google.android.notepad",
Context.CONTEXT_INCLUDE_CODE + Context.CONTEXT_IGNORE_SECURITY);
Class<?> c =
tmpCtxt.getClassLoader().loadClass("the.name.of.a.package.already.deployed.on.the.device");
//do normal Java-Reflection things with c
-------- Code snippet --------
On Apr 10, 5:13 pm, "chris.p" <[EMAIL PROTECTED]> wrote:
> Hello everyone,
>
> is there an easy way for reflection of classes in other packages that
> are currently installed on the device? Class.forName() obviously
> doesn't work since the classes are not on the static classpath. I've
> tried it via the Context.createPackageContext("packagename") method
> which successfully creates the context of the foreign package. But the
> attempt to load the class with getClassLoader().loadClass() called on
> the context-pointer fails with a ClassNotFoundException. I've stumbled
> across a solution on the Internet, where classes were loaded over
> their .dex-Classfile (http://blog.luminis.nl/roller/luminis/entry/
> osgi_on_google_android_using). Is this the only way of using
> reflection on classes in other packages installed on the device?
>
> Thx in advance,
>
> Chris
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---