java - How to get wifi direct devices name from WifiP2pDeviceList -


i want wi-fi direct name when execute request peers, here code:

if (wifip2pmanager.wifi_p2p_peers_changed_action.equals(action)) {      log.d(tag, "success discover peers ");      if (mmanager != null) {         mmanager.requestpeers(mchannel, new wifip2pmanager.peerlistlistener() {              @override             public void onpeersavailable(wifip2pdevicelist peers) {                 // todo auto-generated method stub                  if (peers != null) {                     if (device.devicename.equals("abc")) {                         log.d(tag, "found device!!! ");                          toast.maketext(getapplicationcontext(), "found!!", toast.length_short).show();                      }                 }             }         });     } else {         log.d(tag, "mmaganger == null");     } } 

i want devicename list of peers can found 1 named "abc". idea?

if want others device name:

wifip2pmanager.requestpeers(wifichannel, new wifip2pmanager.peerlistlistener() {         @override         public void onpeersavailable(wifip2pdevicelist wifip2pdevicelist) {              (wifip2pdevice device : wifip2pdevicelist.getdevicelist())             {                 if (device.devicename.equals("abc")) log.d(tag, "found device!!! ");                 // device.devicename             }         }     }); 

if want device name in receiver:

if (action.equals(wifip2pmanager.wifi_p2p_this_device_changed_action)) {     wifip2pdevice device = intent.getparcelableextra(wifip2pmanager.extra_wifi_p2p_device);     // device.devicename } 

if want change device name:

try {     method method = wifip2pmanager.getclass().getmethod("setdevicename",         wifip2pmanager.channel.class, string.class, wifip2pmanager.actionlistener.class);      method.invoke(wifip2pmanager, wifichannel, "new device name", new wifip2pmanager.actionlistener() {         public void onsuccess() {}          public void onfailure(int reason) {}     }); } catch (exception e)   {} 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -