【发布时间】:2012-12-24 16:36:31
【问题描述】:
使用本教程:http://developer.android.com/training/connect-devices-wirelessly/wifi-direct.html#fetch
我已经成功进入教程中的这部分代码:
private List peers = new ArrayList();
...
private PeerListListener peerListListener = new PeerListListener() {
@Override
public void onPeersAvailable(WifiP2pDeviceList peerList) {
// Out with the old, in with the new.
peers.clear();
peers.addAll(peerList.getDeviceList());
// If an AdapterView is backed by this data, notify it
// of the change. For instance, if you have a ListView of available
// peers, trigger an update.
((WiFiPeerListAdapter) getListAdapter()).notifyDataSetChanged();
if (peers.size() == 0) {
Log.d(WiFiDirectActivity.TAG, "No devices found");
return;
}
}
}
我现在不确定将获取对等列表的这段代码放在哪里。它是在我的广播接收器中,还是在 wifi 活动本身中?在哪里?
【问题讨论】:
-
没有。我仍然没有看到它。我不明白它应该在 onRecieve() 的什么位置。对不起,我是新人。
标签: android broadcastreceiver wifi-direct peer