title: Android - How to turn off Wifi-direct
body: <p>I'm kind of new to Java, Android and even Stackoverflow, sorry if my question is not well written.</p>
  
  <p>I followed many guides online that showed me how to connect two devices using Wifi-direct.
  I managed to do this and now I just need to close the connection.</p>
  
  <p>I have a C++ "server" peer and an Android "client" peer and for the client side I am using the Wifi-Direct Demo (linked below)</p>
  
  <ul>
  <li>I create a Wifi-Direct group C++ side</li>
  <li>From Android I search for servers</li>
  <li>The user chooses the server</li>
  <li>Socket connection</li>
  <li>Transmission</li>
  </ul>
  
  <p>Now I don't need the connection anymore, so I want to close it and immediately reconnect both devices to the normal Wifi.</p>
  
  <p>If I try to launch the disconnect() function of the demo, it enter OnSuccess(), but the Wifi-Direct icon simply won't go away;
  Strangely, I can't find any guide at all on how to do this.</p>
  
  <p>There is also another problem with my app... If I am connected, and I close the app, the Wifi-direct icon is still on and I can't connect to Internet using Wifi... I think the socket may still be in the TIME_WAIT status, but I'm not sure on how to check this...</p>
  
  <p>Thank you in advance!</p>
  
  <p>EDIT: some answer that I found useful, but do not show how to turn off Wifi-Direct:
  <a href="http://processors.wiki.ti.com/index.php/OMAP_Wireless_Connectivity_NLCP_WiFi_Direct_Configuration_Scripts#p2p_group_add" rel="nofollow noreferrer">http://processors.wiki.ti.com/index.php/OMAP_Wireless_Connectivity_NLCP_WiFi_Direct_Configuration_Scripts#p2p_group_add</a></p>
  
  <p><a href="https://android.googlesource.com/platform/development/+/master/samples/WiFiDirectDemo/" rel="nofollow noreferrer">https://android.googlesource.com/platform/development/+/master/samples/WiFiDirectDemo/</a></p>
  
  <p><a href="https://stackoverflow.com/questions/16372724/wifi-direct-android">Wi-Fi Direct Android</a></p>
  
  <p><a href="https://stackoverflow.com/questions/7632135/how-to-create-the-server-client-connection-between-android-mobile-and-pc">https://stackoverflow.com/questions/7632135/how-to-create-the-server-client-connection-between-android-mobile-and-pc</a></p>