java隐藏函数调用失败---求教

private void removeAndDeleteGroup(WifiP2pGroup wifiP2pGroup) {
mManager.removeGroup(mChannel, null);
try {
Method getNetworkId = WifiP2pGroup.class.getDeclaredMethod("getNetworkId");
Integer networkId = (Integer) getNetworkId.invoke(wifiP2pGroup);
Method deletePersistentGroup = WifiP2pManager.class.getDeclaredMethod("deletePersistentGroup",
WifiP2pManager.Channel.class, Integer.class, WifiP2pManager.ActionListener.class);
deletePersistentGroup.invoke(mManager, mChannel, networkId, null);
} catch (NoSuchMethodException e) {
Log.e("WIFI", "Could not delete persistent group", e);
} catch (InvocationTargetException e) {
Log.e("WIFI", "Could not delete persistent group", e);
} catch (IllegalAccessException e) {
Log.e("WIFI", "Could not delete persistent group", e);
}
}
显示NoSuchMethodException

4个回答

隐藏函数,是私有函数吗?
如果是,则私有函数只能在类的内部调用,不能像 Public 函数那样使用类的变量调用。

qq_27751729
qq_27751729 getNetworkId和deletePersistentGroup都是public的啊上面程序有什么问题吗?
4 年多之前 回复

java里面有隐藏函数吗?

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问