0

I am finding a way to turn ON WiFi-Direct when internet connectivity is not available but when internet connectivity active and the device is connected to some other device with WiFi-Direct then it preventing to connect with the internet.

My purpose is to turn OFF WiFi-Direct when the internet is available and turn ON WiFi-Direct when the internet not available.

Bhola Nath Mahto
  • 484
  • 5
  • 18
  • For this you have to make one If...Else condition for the Internet connection means If your Internet connection is ON then Disable WI-Fi connection, Else Enable Wi-Fi connection. For Disable and Enable Wi-Fi connection See this http://www.viralandroid.com/2015/12/turn-on-and-off-wifi-connection-programmatically-in-android.html – Vishal Senjaliya May 19 '17 at 11:56
  • @ERVishalSenjaliya I am doing the same thing but this is for normal wifi, my purpose is to target wifi-direct. – Bhola Nath Mahto May 19 '17 at 12:00
  • Second way, Try to understand this SO http://stackoverflow.com/questions/36098871/how-to-search-and-connect-to-a-specific-wifi-network-in-android-programmatically Because First time You have to find the available Wi-Fi connection and then automatically connect that WI-Fi conn and For this process Broadcast Reciever is the main part. – Vishal Senjaliya May 19 '17 at 12:13

0 Answers0