获得WifiP2pDeviceList WifiP2pDevice信息 [英] get WifiP2pDevice information from WifiP2pDeviceList

查看:1231
本文介绍了获得WifiP2pDeviceList WifiP2pDevice信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发使用wifi-direct.So到目前为止,我能得到onPeersAvailable方法内检测到的设备两款Android设备之间发送数据的Andr​​oid应用。 (下面给出的code)

I am developing an android application which sends data between two android devices using wifi-direct.So far i was able to get the detected device inside onPeersAvailable method . (the code given below)

@Override
public void onPeersAvailable(WifiP2pDeviceList peers) {

                        peersdevices.clear();
                        peersdevices.addAll(peers.getDeviceList());

}

现在我想在列表视图中显示的设备名称。我不知道如何访问每个 WifiP2pDevice 信息 WifiP2pDeviceList

Now i want to display the devices name in a list view. I don't know how to access each WifiP2pDevice information from WifiP2pDeviceList.

当我使用的官方文档以下code(如下),我得到一个错误无法从对象转换为WifiP2pDevice。

When i used the following code from official documentation (given below), i get an error "cannot convert from Object to WifiP2pDevice" .

WifiP2pDevice device = peers.get(0);

我应该心存感激,如果有人提供了code段来获得WifiP2pDeviceList WifiP2pDevice信息。

I will be thankful if anyone provides the code snippet to get WifiP2pDevice information from WifiP2pDeviceList.

感谢

推荐答案

做这样的。

for(i=0;i<WifiP2pDeviceList.size();i++){
    WifiP2pDevice device = WifiP2pDeviceList.get(i);
    String deviceName=device.deviceName;
    String devicestatus=device.status;
    //so on
    }

希望它能帮助

这篇关于获得WifiP2pDeviceList WifiP2pDevice信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆