1.fragment is the accessibilityfragment of the image. The type of method that needs to be adjusted.
setaccessible (true) does not change the access permission for a method to public. Instead, the permission control check for Java is canceled. So even the public method. Its accessible zodiac default is also false
try {
Class mClass = Class.forName ("Com.sonymobile.chameleon.workflow.step.AccessibilityFragment");
method = Mclass.getdeclaredmethod (" Isaccessibilityenabled ");
method.setaccessible (true);
if (! Boolean.parseboolean ((Method.invoke ((Object) fragment,null) + "")) {
method = Mclass.getdeclaredmethod ("enableaccessibility");
Method.setaccessible (TRUE);//Private Method
Method.invoke ((Object) fragment,null);//method of adjustment, NULL: The parameter to pass
Method.invoke (Object) GetService (), New Object[]{getcontext ()});
}
} catch (ClassNotFoundException e) {
LOG.D (TAG, "1");
E.printstacktrace ();
} catch (Nosuchmethodexception e) {
LOG.D (TAG, "2");
E.printstacktrace ();
} catch (Illegalaccessexception e) {
LOG.D (TAG, "3");
E.printstacktrace ();
} catch (IllegalArgumentException e) {
LOG.D (TAG, "4");
E.printstacktrace ();
} catch (InvocationTargetException e) {
LOG.D (TAG, "5");
E.printstacktrace ();
}
Using the Java reflection mechanism to implement calling private methods