android - Reflection on PackageManager fails -
I am trying to reach See method definition You must pass the Change PackageManager via reflection. I can calculate the methods and find getApplicationInfo. I can also execute
getApplicationInfo on the basis of context I
gets reflection through GetMethods () but
getMethod () with
getApplicationInfo a
no such exception exception .
method of law; Law method 2; Method = Class.forName (Context.class.getName ()). GetDeclaredMethod ("getPackageManager"); Object manager; Manager = method.invoke (ctx); // This works ApplicationInfo testInfo = (PackageManager Manager). GetApplicationInfo ("com.package.class", 0); // throws nosuchmethodexception (PackageManager Manager) .getClass () GetMethod ("getApplicationInfo");
public method getDeclaredMethod (string name, class ...
class example of the parameter types.
(PackageManager Manager) .getClass () GetMethod ("GetApplicationInfo");
(PackageManager manager) .getClass () GetMethod ("getApplicationInfo", int.class); < / Code>
Comments
Post a Comment