Quantcast
Channel: Questions in topic: "unitywebplayer"
Viewing all articles
Browse latest Browse all 452

Enable/Disable Wifi on Android device

$
0
0
Hello, I am trying to enable or disable Wifi from Unity on my Android device. I tried to do the different things I found on the forum without success. If I do: using(var unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer")) { string wifiServiceName = unityPlayer.Get("WIFI_SERVICE"); using(var wifiManager = unityPlayer.Call("getSystemService", wifiServiceName)) { wifiManager.Call("setWifiEnabled", false); } } I have an error saying that WIFI_SERVICE doesn't exist. If I do: using (AndroidJavaObject activity = new AndroidJavaClass("com.unity3d.player.UnityPlayer").GetStatic("currentActivity")) { using (var wifiManager = activity.Call("getSystemService","wifi")) { wifiManager.Call("setWifiEnabled", false); } } I have an error saying that setWifiEnabled is not a function, (nor a static function if I do CallStatic). I have my manifest.xml correctly merged, I can check that I have all the permissions on the application manager. I spent few hours trying to figure out how to do that and I am stuck! Does anyone know a simple way to do so? Thanks a lot for your help, Benjamin

Viewing all articles
Browse latest Browse all 452

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>