android - Reflection on PackageManager fails -
I am trying to reach 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"); See method definition public method getDeclaredMethod (string name, class ... You must pass the class example of the parameter types. Change (PackageManager Manager) .getClass () GetMethod ("GetApplicationInfo"); (PackageManager manager) .getClass (...