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 () GetMethod ("getApplicationInfo", int.class); < / Code>   

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -