我想创建一个组以使当前设备平板电脑作为接入点,但是在回调方法中onGroupInfoAvailable()
我得到了组的空指针。为什么?
manager = (WifiP2pManager) getSystemService(Context.WIFI_P2P_SERVICE);
channel = manager.initialize(this, getMainLooper(), null);
manager.createGroup(channel, new ActionListener() {
@Override
public void onSuccess() {
manager.requestGroupInfo(channel, new GroupInfoListener() {
public void onGroupInfoAvailable(WifiP2pGroup group) {
if(group != null)
Toast.makeText(SasetBladderPadActivity.this, "Group Passphrase: "
+ group.getPassphrase(), Toast.LENGTH_LONG).show();
else
Toast.makeText(SasetBladderPadActivity.this, "Group is null ",
Toast.LENGTH_LONG).show();
}
});
}
@Override
public void onFailure(int arg0) {
// TODO Auto-generated method stub
Toast.makeText(SasetBladderPadActivity.this, "Create group failed: " + arg0, \
Toast.LENGTH_LONG).show();
}
});