Is there an API to turn On/Off the WiFi HotSpot on Android programmatically?
What methods should I call to turn it On/Off?
UPDATE:There's this option to have the HotSpot enabled, and just turn On/Off the WiFi, but this is not a good solution for me.
Your best bet will be looking at the WifiManager class. Specifically the
setWifiEnabled(bool)
function.See the documentation at: http://developer.android.com/reference/android/net/wifi/WifiManager.html#setWifiEnabled(boolean)
A tutorial on how to use it (including what permissions you need) can be found here: http://www.tutorialforandroid.com/2009/10/turn-off-turn-on-wifi-in-android-using.html
**For Oreo & PIE ** I found below way through this
UseAge
You can use the following code to enable, disable and query the wifi direct state programatically.
where status may be
true
orfalse
add permission manifest:
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />