android - Check that wifi direct is connected -
i need check phone connected wifi direct phone play, developed on framework of andengine.
protected boolean conectadowifi(){ wifip2pmanager connectivity=(wifip2pmanager)activity.getsystemservice(context.wifi_p2p_service); final wifip2pmanager.channel channel = connectivity.initialize(activity, activity.getmainlooper(), new wifip2pmanager.channellistener() { @override public void onchanneldisconnected() { } }); connectivity.discoverpeers(channel, new wifip2pmanager.actionlistener() { @override public void onsuccess() { if (wifip2pmanager.wifi_p2p_state_enabled == 2) { // wifi direct mode enabled system.out.println("-----------wifi direct on-"); } if (wifip2pmanager.wifi_p2p_state_disabled==1){ system.out.println("-----------wifi direct off-"); } } @override public void onfailure(int i) { system.out.println("+++++++++++off wifi++++++++++++++"); } }); return true; }
Comments
Post a Comment