2 qq 27751729 qq_27751729 于 2016.01.18 16:31 提问

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个回答

caozhy
caozhy   Ds   Rxr 2016.01.18 21:33
caozhy
caozhy   Ds   Rxr 2016.01.18 21:33
shuxmpx145
shuxmpx145   2016.01.18 17:08

java里面有隐藏函数吗?

91program
91program   Ds   Rxr 2016.01.18 16:36

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

qq_27751729
qq_27751729 getNetworkId和deletePersistentGroup都是public的啊上面程序有什么问题吗?
接近 2 年之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!