Class[] getArgArray = null;
Class[] setArgArray = new Class[] {boolean.class};
Object[] getArgInvoke = null;
try {
Method mGetMethod = conManager.getClass().getMethod("getMobileDataEnabled", getArgArray);
Method mSetMethod = conManager.getClass().getMethod("setMobileDataEnabled", setArgArray);
boolean isOpen = (Boolean) mGetMethod.invoke(conManager, getArgInvoke);
if (isOpen) {
mSetMethod.invoke(conManager, false);
} else {
mSetMethod.invoke(conManager, true);
}
} catch (Exception e) {
e.printStackTrace();
}
以上是java代码,用NS实现到getMethod,控制台提示getMethod方法不存在
0 个回复